Expand On Clause
Translation reference to convert Teradata Expand On functionality to Snowflake
Description
The Expand On clause expands a column having a period data type, creating a regular time series of rows based on the period value in the input row. For more information about Expand On clause, see the Teradata documentation.
Sample Source Patterns
Some parts in the output code are omitted for clarity reasons.
Sample data
Expand On Clause
Suppose you want to expand the period column by seconds, for this Expand On clause has anchor period expansion and interval literal expansion.
Anchor Period Expansion
Snowflake doesn't support Expand On clause. To reproduce the same results and functionality, the Teradata SQL code will be contained in a CTE block, with an EXPAND_ON_UDF and TABLE function, using FLATTEN function to return multiple rows, ROW_COUNT_UDF and DIFF_TTIME_PERIOD_UDF to indicate how many rows are needed and returning VALUE to help the EXPAND_ON_UDF to calculate the different regular time series. This CTE block returns the same expand columns alias as in the Expand On clause, so the result can be used in any usage of period datatype.
Known Issues
The Expand On clause can use interval literal expansion, for this case, SnowConvert will add an error that this translation is planned.
Interval literal expansion
Related EWIs
SSC-EWI-0073: Pending Functional Equivalence Review.
SSC-EWI-TD0053: Snowflake does not support the period datatype, all periods are handled as varchar instead.
Last updated