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
Retrieve a Value from Filename Metadata
To retrieve a value from a key-value pair in the filename metadata, specify the first argument as
'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
Loads a variety of header metadata along with each record of the data pipeline.
SQL
Supported Values for the Metadata Key
The metadata values you can load differ based on the source type. This table lists the available values for the metadata keys specified using the
key argument by source type and their returned data type. Metadata key values are not case-sensitive.
Examples
Load Filename Metadata
This example snippet uses the
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

