STRUCT
Translation specification for the STRUCT datatype from BigQuery to Snowflake.
Description
In BigQuery, a container of ordered fields each with a type (required) and field name (optional). See Struct Type.
In Snowflake, OBJECT_CONSTRUCT can be used to emulate the STRUCT behavior, and SnowConvert handles most implementation differences.
Sample Source Patterns
Setup data
CREATE OR REPLACE TABLE test.structTypes
(
COL1 STRUCT<sc1 INT64>,
COL2 STRUCT<sc2 STRING(10)>,
COL3 STRUCT<sc3 STRUCT<sc31 INT64, sc32 INT64>>,
COL4 STRUCT<sc4 ARRAY<INT64>>,
COL5 STRUCT<sc5 INT64, sc51 INT64>,
COL7 STRUCT<sc7 INT64 OPTIONS(description = "A repeated STRING field"), sc71 BOOL>,
COL8 STRUCT<sc8 INT64 NOT NULL, sc81 BOOL NOT NULL OPTIONS(description = "A repeated STRING field")>
);
CREATE OR REPLACE TABLE test.tuple_sample (
COL1 STRUCT<Key1 INT64, Key2 INT64>
);CREATE OR REPLACE TABLE test.structTypes
(
COL1 VARIANT /*** SSC-FDM-BQ0009 - STRUCT<INT> CONVERTED TO VARIANT. SOME OF ITS USAGES MIGHT HAVE FUNCTIONAL DIFFERENCES. ***/,
COL2 VARIANT /*** SSC-FDM-BQ0009 - STRUCT<STRING(10)> CONVERTED TO VARIANT. SOME OF ITS USAGES MIGHT HAVE FUNCTIONAL DIFFERENCES. ***/,
COL3 VARIANT /*** SSC-FDM-BQ0009 - STRUCT<STRUCT<INT64, INT64>> CONVERTED TO VARIANT. SOME OF ITS USAGES MIGHT HAVE FUNCTIONAL DIFFERENCES. ***/,
COL4 VARIANT /*** SSC-FDM-BQ0009 - STRUCT<> CONVERTED TO VARIANT. SOME OF ITS USAGES MIGHT HAVE FUNCTIONAL DIFFERENCES. ***/,
COL5 VARIANT /*** SSC-FDM-BQ0009 - STRUCT<INT, INT> CONVERTED TO VARIANT. SOME OF ITS USAGES MIGHT HAVE FUNCTIONAL DIFFERENCES. ***/,
COL7 VARIANT /*** SSC-FDM-BQ0009 - STRUCT<INT, BOOLEAN> CONVERTED TO VARIANT. SOME OF ITS USAGES MIGHT HAVE FUNCTIONAL DIFFERENCES. ***/,
COL8 VARIANT /*** SSC-FDM-BQ0009 - STRUCT<INT, BOOLEAN> CONVERTED TO VARIANT. SOME OF ITS USAGES MIGHT HAVE FUNCTIONAL DIFFERENCES. ***/
);
CREATE OR REPLACE TABLE test.tuple_sample (
COL1 VARIANT /*** SSC-FDM-BQ0009 - STRUCT<INT, INT> CONVERTED TO VARIANT. SOME OF ITS USAGES MIGHT HAVE FUNCTIONAL DIFFERENCES. ***/
);Insert INT Data Type to STRUCT column
Input Code:
Output Code:
Insert STRING Data Type to STRUCT column
Input Code:
Output Code:
Insert STRUCT Data Type to STRUCT column
Input Code:
Output Code:
Insert ARRAY Data Type to STRUCT column
Input Code:
Output Code:
Insert to selected STRUCT columns
Input Code:
Output Code:
Insert to STRUCT column tuple syntax
Translation of tuple syntax values is currently not supported.
Input Code:
Output Code:
Update STRUCT column
Input Code:
Output Code:
Update STRUCT column field
Input Code:
Output Code:
Select from STRUCT column
Input Code:
Output Code:
Select from STRUCT column tuple syntax
Input Code:
Output Code:
Create a view using an anonymous STRUCT definition
Input Code:
Output Code:
STRUCT column comparison expressions
BigQuery comparison operations for Structs compare value to value, ignoring the key if it exists, while Snowflake comparison operations for Objects compare both, value and key. This may cause that some comparisons return a different result.
Input Code:
Output Code:
Related EWIs
SSC-FDM-BQ0010: Struct converted to VARIANT. Some of its usages might have functional differences.
SSC-EWI-BQ0012: Unable to generate correct OBJECT_CONSTRUCT parameter.
SSC-FDM-BQ0008: Where clause references a column of STRUCT type.
Last updated
