ARRAY<T>
Translation specification for the ARRAY<T> datatype from BigQuery to Snowflake
Description
In BigQuery, an array is an ordered list of zero or more elements of non-array values. Elements in an array must share the same type. (Array Type. BigQuery)
Sample Source Patterns
Setup data
Input Code:
CREATE TABLE test.arrayTable
(
col1 ARRAY<INT64>
);
CREATE TABLE test.anotherArrayTable
(
col2 ARRAY<INT64>
);
INSERT INTO test.arrayTable VALUES ([4, 10, 55]);
INSERT INTO test.arrayTable VALUES ([6, 7, 33]);
INSERT INTO test.arrayTable VALUES ([50, 12, 22]);
INSERT INTO test.anotherArrayTable VALUES ([9, 11, 52]);
INSERT INTO test.anotherArrayTable VALUES ([3, 18, 11]);
INSERT INTO test.anotherArrayTable VALUES ([33, 27, 43]);Output Code:
ARRAY access by index
Input Code:
Output Code:
Safe ARRAY access by index
Input Code:
Output Code:
INSERT with ARRAY in the VALUES clause
Input Code:
Output Code:
MERGE statement
Input Code:
Output Code:
ARRAY DEFAULT column value insertion/update
Input Code:
Output Code:
INSERT/UPDATE with NULL value
Input Code:
Output Code:
ARRAY concatenation
Input Code:
Output Code:
ARRAY used as parameter/return type
Input Code:
Output Code:
Known Issues
1. Non-safe ARRAY access will not fail for positive out of bounds indexes
In BigQuery, accessing an array element by index will fail for any index value that is too low (underflow) or too high (overflow) when not using SAFE_OFFSET or SAFE_ORDINAL. However, in Snowflake errors are thrown only for underflow cases, any index that would case an overflow error will generate a NULL value instead.
When non-safe access to elements in an array is detected SnowConvert will generate SSC-FDM-BQ0001 to warn the user about this.
Related EWIs
SSC-FDM-BQ0001: Accessing arrays produces NULL instead of an error for positive out of bounds indexes in Snowflake.
Last updated
