FME Transformers: 2024.2
FME Transformers: 2024.2
SchemaScanner
Produces a schema feature representing the feature type definition for each group of input data features.
Typical Uses
-
Generating a schema feature for dynamic writers
-
Generating schema features for comparison for schema validation and schema drift
-
Generating schemas after merging or manipulating datasets
How does it work?
The SchemaScanner receives features and determines their schema by scanning for attribute names and data types, based on the features' structure and attribute values.
It will scan either all features or a specified number of them, and can exclude certain attributes based on names, such as format-specific or internal FME attributes.
The resulting schema is output as a new schema feature, which has a specific form of list attribute and is output via the <Schema> port. It also receives a special attribute and value: fme_schema_handling = ‘schema_only’, which tells a dynamic writer to use that feature as a schema and then remove it from the output.
The original input features are passed out via the Output port.
The output order of the schema features relative to the data (input features) can be controlled using the Output Schema Before Data Features. For use with dynamic writers, the schema features should be output first.
Attribute Generation
Schemas can be generated with either standard data types or explicitly defined ones, according to the Numeric and String Data Types parameters:
-
Standard Types produces types such as fme_real64 , fme_int8 and fme_buffer.
-
Explicit Width and Precision produces types such as:
-
fme_decimal(a,b) where a is the number of digits before a decimal, and b the number of digits after (precision).
-
fme_varchar(a) where a is the maximum number of characters in a string.
-
When using Explicit Width and Precision, consider scanning all features (Number of Features to Scan) to ensure all existing attribute value lengths are considered.
Working with Dates
Dates and times may be optionally scanned for.
If strings match the FME datetime format of %Y%m%d%H%M%S they may be scanned for with Detect FME Dates .
To scan for strings that match another date or time format, use Convert Input Date Format to FME Date . Note that this option is only available if Output Schema Before Data Features is set to Yes.
See Standard FME Date/Time Format for formatting details.
Excluding Attributes
SchemaScanner processes all attributes on incoming features, including fme and format attributes. It is possible to ignore attributes using the Ignore Attributes Containing parameter.
Enter a regular expression, and matching attributes will be ignored.
For example, if the source data is CSV, you could use the regular expression ^fme_|^multi_|^csv_ to ignore any attributes starting with fme_, multi_, or csv_.
Schema Features
Schema features can be used to store or pass along schema structures - to dynamic writers, for example. The schema is stored in a list attribute named attribute, as shown here.
Each attribute has a name and an fme_data_type - note the attribute LAT has a corresponding data type of fme_real64.
Data types are FME internal data types.
Usage Notes
- Schema features may also be generated manually, or by using the FeatureReader's schema options. Two readers also generate schemas - the Schema (Any Format) reader and the Schema (From Table) reader.
- When using the SchemaScanner with a dynamic writer, the Output Schema Before Data Features parameter should be set to Yes, so that the schema arrives at the writer prior to the data features.
Configuration
Input Ports
Input
This transformer accepts any feature.
Output Ports
Output
All data features that were input are output here, with a Schema Definition Name attribute added as specified in parameters.
Features will be unaltered unless Convert Input Date Format to FME Date is used.
The original order of the features may change if Group Processing is enabled.
<Schema>
One or more Schema Features - depending on whether Group Processing is enabled. Each schema feature has a list attribute in the form:
attribute{}.name
attribute{}.fme_data_type
One element for every attribute in the input data features.
The transformer adds a special attribute and value:
fme_schema_handling = ‘schema_only’
Parameters
Group Processing
Group By |
If Group By attributes are selected, features with the same values in the Group By attributes are grouped together, and one schema per group will be produced. |
||||
Complete Groups |
Select the point in processing at which groups are processed:
Considerations for Using Group By
There are two typical reasons for using When Group Changes (Advanced) . The first is incoming data that is intended to be processed in groups (and is already so ordered). In this case, the structure dictates Group By usage - not performance considerations. The second possible reason is potential performance gains. Performance gains are most likely when the data is already sorted (or read using a SQL ORDER BY statement) since less work is required of FME. If the data needs ordering, it can be sorted in the workspace (though the added processing overhead may negate any gains). Sorting becomes more difficult according to the number of data streams. Multiple streams of data could be almost impossible to sort into the correct order, since all features matching a Group By value need to arrive before any features (of any feature type or dataset) belonging to the next group. In this case, using Group By with When All Features Received may be the equivalent and simpler approach. Note Multiple feature types and features from multiple datasets will not generally naturally occur in the correct order.
As with many scenarios, testing different approaches in your workspace with your data is the only definitive way to identify performance gains. |
General
Output Schema Before Data Features |
Select an ordering option for the schema features:
|
Number of Features to Scan |
Specify the number of features to scan to determine the dataset schema. If blank, all features are scanned. If this number is greater than the number of features received, all features are scanned. For very large datasets, setting this parameter may improve performance. The default is blank - scan all features. |
Ignore Attributes Containing |
Enter a regular expression. Attributes with matching names will be excluded from the schema. |
Include Format Attributes
|
Choose if format attributes should be included on the schema.
Format attributes are determined from each feature’s multi_reader_type attribute if present. |
Ignore Attributes |
Select case sensitivity - Case Sensitive or Case Insensitive -for Ignore Attributes Containing regular expression matching. |
Data Types
Numeric |
Select the type of numeric value handling to be used in the schema:
|
String |
Select the type of string value handling to be used in the schema:
|
Missing/Null/Empty Attributes |
Select a method for handling attributes without values:
|
Date Handling
Select a method for interpreting date and time strings.
See also Standard FME Date/Time Format
No Date Detection |
Ignore dates. |
Detect FME Dates (%Y%m%d%H%M%s$) |
Detect datetime strings matching FME standard date/time format. |
Convert Input Date Format to FME Date |
When Output Schema Before Data Features is set to Yes, non-FME datetime formats may be detected and converted. Select a single format from the available options or enter a custom string. Note Output features may be altered (not only scanned) using this option, and so the schema must be output first. Consider using the Number of Features to Scan parameter to improve performance.
|
Output Attribute Names
Schema Definition Name |
Name the attribute to contain the generated schema definition name, to be added to all output data features. This attribute is typically used by a <dynamic> writer to link the schema to the data. The default attribute name, fme_feature_type_name, can be used on the corresponding dynamic writer Schema Definition Name parameter. |
Editing Transformer Parameters
Transformer parameters can be set by directly entering values, using expressions, or referencing other elements in the workspace such as attribute values or user parameters. Various editors and context menus are available to assist. To see what is available, click beside the applicable parameter.
How to Set Parameter Values
Defining Values
There are several ways to define a value for use in a Transformer. The simplest is to simply type in a value or string, which can include functions of various types such as attribute references, math and string functions, and workspace parameters.
Using the Text Editor
The Text Editor provides a convenient way to construct text strings (including regular expressions) from various data sources, such as attributes, parameters, and constants, where the result is used directly inside a parameter.
Using the Arithmetic Editor
The Arithmetic Editor provides a convenient way to construct math expressions from various data sources, such as attributes, parameters, and feature functions, where the result is used directly inside a parameter.
Conditional Values
Set values depending on one or more test conditions that either pass or fail.
Parameter Condition Definition Dialog
Content
Expressions and strings can include a number of functions, characters, parameters, and more.
When setting values - whether entered directly in a parameter or constructed using one of the editors - strings and expressions containing String, Math, Date/Time or FME Feature Functions will have those functions evaluated. Therefore, the names of these functions (in the form @<function_name>) should not be used as literal string values.
Content Types
These functions manipulate and format strings. | |
Special Characters |
A set of control characters is available in the Text Editor. |
Math functions are available in both editors. | |
Date/Time Functions | Date and time functions are available in the Text Editor. |
These operators are available in the Arithmetic Editor. | |
These return primarily feature-specific values. | |
FME and workspace-specific parameters may be used. | |
Creating and Modifying User Parameters | Create your own editable parameters. |
Dialog Options - Tables
Table Tools
Transformers with table-style parameters have additional tools for populating and manipulating values.
Row Reordering
|
Enabled once you have clicked on a row item. Choices include:
|
Cut, Copy, and Paste
|
Enabled once you have clicked on a row item. Choices include:
Cut, copy, and paste may be used within a transformer, or between transformers. |
Filter
|
Start typing a string, and the matrix will only display rows matching those characters. Searches all columns. This only affects the display of attributes within the transformer - it does not alter which attributes are output. |
Import
|
Import populates the table with a set of new attributes read from a dataset. Specific application varies between transformers. |
Reset/Refresh
|
Generally resets the table to its initial state, and may provide additional options to remove invalid entries. Behavior varies between transformers. |
Note: Not all tools are available in all transformers.
For more information, see Transformer Parameter Menu Options.
Reference
Processing Behavior |
|
Feature Holding |
If Output Schema Features Before Data is Yes then the transformer will block all the incoming data features. This is usually required if you are using the schema feature with a dynamic writer. Target Number of Features to Scan will also block the data features - up to the number of features selected (or all features, if left blank). |
Dependencies | None |
Aliases | |
History |
FME Community
The FME Community has a wealth of FME knowledge with over 20,000 active members worldwide. Get help with FME, share knowledge, and connect with users globally.
Search for all results about the SchemaScanner on the FME Community.
Examples may contain information licensed under the Open Government Licence – Vancouver, Open Government Licence - British Columbia, and/or Open Government Licence – Canada.