SSC-FDM-BQ0008

Where clause references a column of STRUCT type.

Description

If an Snowflake Object has a key value format, when a comparison is made with another Object, Snowflake compares both key and value. On the other hand, when BigQuery compares between Structs, it compares only values, regardless if the Struct has keys or not.

This difference between comparisons may cause that the results are not the same in SnowConvert and BigQuery for the same comparison. This FDM is added when a comparison is made on a Snowflake Object created from a BigQuery Struct.

Code Example

Input:

IN -> BigQuery_01.sql
CREATE OR REPLACE TABLE test.compExprTable
(
  COL1 STRUCT<sc1 INT64>,
  COL2 STRUCT<sc2 INT64>  
);

SELECT * FROM test.compExprTable WHERE COL1 <> (COL2);

Output:

OUT -> BigQuery_01.sql
CREATE OR REPLACE TABLE compExprTable
(
  COL1 VARIANT /*** SSC-FDM-BQ0009 - STRUCT<INT> CONVERTED TO VARIANT. REVIEW FUNCTIONALITY FOR POTENTIAL CHANGES. ***/,
  COL2 VARIANT /*** SSC-FDM-BQ0009 - STRUCT<INT> CONVERTED TO VARIANT. REVIEW FUNCTIONALITY FOR POTENTIAL CHANGES. ***/
);

SELECT * FROM
test.structTypes2
--** SSC-FDM-BQ0008 - WHERE CLAUSE REFERENCES A COLUMN OF STRUCT TYPE. COMPARISON OPERATIONS MAY PRODUCE DIFFERENT RESULTS IN SNOWFLAKE. **
WHERE COL1 <> (COL2);

Recommendations

Last updated