METADATA function can load a variety of metadata along with each record of the data pipeline, or it can use key-value pairs to return the value in the filename metadata.
Load Metadata into a Column
To load a metadata value into a column, use the METADATA function in the SELECT SQL statement and replace key with the key you want to load. You can use transformation functions to achieve the final data type or allow the pipeline to apply automatic casting.
SQL
| Argument | Data Type | Description |
|---|---|---|
key | string | The name of the specified metadata key. Example: 'topic' |
'hive_partition' and provide a search string for the key. In this case, the filename must follow Hive naming standards. The standard embeds field names and key-value pairs in path segments, such as /year=2019/month=2/data.parquet. If there are duplicate key-value pairs in the filename, the function uses the last pair. The function returns a string with the value of the associated key, and returns NULL if the file does not contain the search string or the filename does not follow Hive naming standards.
SQL
| Argument | Data Type | Description |
|---|---|---|
search_string | string | The search string to use as a key for searching the filename metadata to return the value from the key-value pair as a string. |
SQL
| Argument | Data Type | Description |
|---|---|---|
header_row_index | integer | The index, which starts at 1, of the header row to load. |
header_col_index | integer | The index, which starts at 1, of the header column to load. |
key argument by source type and their returned data type. Metadata key values are not case-sensitive.
| Metadata Key | Source Type | Returned Value Data Type | Description |
|---|---|---|---|
row_id | File Load and Kafka Load | UUID | A unique row identifier that is generated by the Ocient System during loading. The Ocient System guarantees this identifier is unique for each loaded record because the generation is based on internal mechanisms that enforce record deduplication. |
filename | File Load | VARCHAR | The filename and full file path indicate the source of the record. |
file_modified_timestamp | File Load | TIMESTAMP | The timestamp that indicates when the file was last modified on the data source. |
header | Delimited File Load | VARCHAR | Returns the string representation of the header field for the specified header row and column. Returns NULL if any of these conditions exist: The specified field is not present. The specified field is empty, and the EMPTY_FIELD_AS_NULL delimited extract option is set to true.The specified field matches one of the strings in the NULL_STRINGS delimited extract option. |
key | Kafka Load | VARBINARY | The bytes of the Kafka key for the record. |
line_number | File Load | BIGINT | The line number in the file for the source of the record. |
offset | Kafka Load | BIGINT | The Kafka offset of the record. |
partition | Kafka Load | BIGINT | The name of the Kafka partition that indicates the source of the record. |
record | File and Kafka Load | VARCHAR | The string representation of the full record. For delimited, JSON, and binary formats, the system represents the record in the same way as the source. For XML, ASN.1, and formats, the system represents the record as a JSON object. |
record_timestamp | Kafka Load | TIMESTAMP | The timestamp that indicates when the record was created in the Kafka Broker. |
source_record_id | File and Kafka Load | UUID | A unique source row identifier that is generated by the Ocient System during loading. The Ocient System guarantees this unique identifier for each source record with a specific SOURCE and EXTRACT configuration because the generation is based on source names, source record numbers, and source record offsets. |
topic | Kafka Load | VARCHAR | The name of the Kafka topic that indicates the source of the record. |
CREATE PIPELINE SQL statement to load data and the source filename with each record in a pipeline. For details about this pipeline definition and setup, see Data Pipeline Load of CSV Data from S3.
SQL
CREATE PIPELINE SQL statement to load data and the value of the search string 'year' of the filename with each record in a pipeline. The S3 FILTER option contains the filter for the year in a file path. In turn, the METADATA function uses the filter 'year' value to load all records from files with the year 2019 in the specified path. For details about this pipeline definition and setup, see Data Pipeline Load of CSV Data from S3. The example assumes the filename follows Hive-style naming standards.
SQL

