- Categories:
GENERATE_ COLUMN_ DESCRIPTION¶
Generates a list of columns from a set of staged files that contain semi-structured data using the INFER_SCHEMA function output.
The output from this function can be used as input when manually creating a table, external table, Apache Iceberg™ table, or view (using the appropriate CREATE <object> command) based on the column definitions of the staged files.
Alternatively, the CREATE TABLE or CREATE ICEBERG TABLE command with the USING TEMPLATE clause can be used to create a new table with the column definitions derived from the same INFER_SCHEMA function output.
Syntax¶
Arguments¶
exprOutput of the INFER_SCHEMA function formatted as an array.
'string'Type of object that could be created from the column list. The appropriate formatting for this type is applied to the output.
Possible values are
table,external_table, orview.
Returns¶
The function returns the list of columns in a set of staged files, which can be used as input when creating an object of the type identified in the second argument.
Examples¶
Detect, format, and output the set of column definitions in a set of Parquet files staged in the mystage stage. The output columns are
formatted for creating a table.
This example builds on an example in the INFER_SCHEMA topic:
Same as the previous example, but generates a set of columns formatted for creating an external table:
Same as the previous examples, but generates a set of columns formatted for creating an Iceberg table:
Same as the previous examples, but generates a set of columns formatted for creating a view:
Note
Using * for ARRAY_AGG(OBJECT_CONSTRUCT()) might result in an error if the returned result is larger
than 128 MB. Avoid using * for larger result sets, and only use the required columns, COLUMN NAME,
TYPE, and NULLABLE, for the query. You can include the optional column ORDER_ID when using
WITHIN GROUP (ORDER BY order_id).