SnowConvert AI - BigQuery - Data types¶
Snowflake provides support for the majority of fundamental SQL data types, with specific restrictions, across various SQL constructs including columns, local variables, expressions, and parameters.
Boolean Data Type¶
BigQuery |
Snowflake |
Notes |
|---|---|---|
Bytes Data Type¶
Datetime Data Types¶
Geography Data Type¶
Interval Data Type¶
BigQuery |
Snowflake |
Notes |
|---|---|---|
INTERVAL data type is not supported in Snowflake. VARCHAR is used instead. For more information, please refer to the INTERVAL data type documentation. |
Json Data Type¶
Numeric Data Types¶
BigQuery |
Snowflake |
Notes |
|---|---|---|
INT is an alias for the NUMBER data type in Snowflake. The maximum precision and scale is NUMBER(38,37). |
||
INT is an alias for the NUMBER data type in Snowflake. The maximum precision and scale is NUMBER(38,37). |
||
SMALLINT is an alias for the NUMBER data type in Snowflake. The maximum precision and scale is NUMBER(38,37). |
||
INTEGER is an alias for the NUMBER data type in Snowflake. The maximum precision and scale is NUMBER(38,37). |
||
BIGINT is an alias for the NUMBER data type in Snowflake. The maximum precision and scale is NUMBER(38,37). |
||
TINYINT is an alias for the NUMBER data type in Snowflake. The maximum precision and scale is NUMBER(38,37). |
||
BYTEINT is an alias for the NUMBER data type in Snowflake. The maximum precision and scale is NUMBER(38,37). |
||
NUMERIC is an alias for the NUMBER data type in Snowflake. The maximum precision and scale is NUMBER(38,37). |
||
DECIMAL is an alias for the NUMBER data type in Snowflake. The maximum precision and scale is NUMBER(38,37). |
||
Snowflake does not support the BIGNUMERIC data type. Use NUMERIC instead. BIGNUMERIC’s precision 76,76 exceeds Snowflake’s limit (38), resulting in truncation or rounding, which can introduce significant inaccuracies. |
||
Snowflake does not support the BIGDECIMAL data type. Use NUMERIC instead. BIGDECIMAL’s precision 76,76 exceeds Snowflake’s limit (38), resulting in truncation or rounding, which can introduce significant inaccuracies. |
||
String Data Types¶
ANY TYPE¶
Translation specification for BigQuery’s ANY TYPE data type
Description¶
The following is an extract of information about the usage of ANY TYPE within CREATE FUNCTION statements.
A parameter with a type equal to
ANY TYPEcan match more than one argument type when the function is called.
If more than one parameter has type
ANY TYPE, then BigQuery doesn’t enforce any type relationship between these arguments.The function return type cannot be
ANY TYPE. It must be either omitted, which means to be automatically determined based onsql_expression, or an explicit type.Passing the function arguments of types that are incompatible with the function definition results in an error at call time.
Sample source patterns¶
Type definition for UDFs¶
ANY TYPE can only be found as the type for a function’s parameter. SnowConvert AI automatically translates ANY TYPE to VARIANT.
BigQuery¶
Snowflake¶
ARRAY<T>¶
Translation specification for the ARRAY
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¶
BigQuery¶
Snowflake¶
ARRAY access by index¶
BigQuery¶
Snowflake¶
Safe ARRAY access by index¶
BigQuery¶
Snowflake¶
INSERT with ARRAY in the VALUES clause¶
BigQuery¶
Snowflake¶
MERGE statement¶
BigQuery¶
Snowflake¶
ARRAY DEFAULT column value insertion/update¶
BigQuery¶
Snowflake¶
INSERT/UPDATE with NULL value¶
BigQuery¶
Snowflake¶
ARRAY concatenation¶
BigQuery¶
Snowflake¶
ARRAY used as parameter/return type¶
BigQuery¶
Snowflake¶
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 AI will generate SSC-FDM-BQ0001 to warn the user about this.
BYTES¶
Bytes data type and usages
Description¶
Sequence of bytes with a maximum of L bytes allowed in the binary string. The maximum length is 8 MB (8,388,608 bytes). For more information please refer to BigQuery BYTES data type.
Note
BYTES data type is not supported in Snowflake, currently transformed to BINARY.
Sample Source Patterns¶
BYTES output format¶
The default output format for binary data types in BigQuery is ‘BASE64’ and in Snowflake ‘HEX’. For this reason, when a binary column is selected, the BASE64_ENCODE function is automatically added. In order to maintain the default formatting of BigQuery.
BigQuery¶
Snowflake:¶
In case it is not added automatically and you want to see the data in BASE64 format, you can use the BASE64_ENCODE function or set the BINARY_OUTPUT_FORMAT format.
BYTES Literal¶
The following cases represent the forms that can be used to format byte literals in BigQuery.
These literals are not supported in Snowflake, but instead the TRY_TO_BINARY function can be used to convert the input expression to a binary value. This function is a special version of TO_BINARY that performs the same operation, but with error handling support.
It is important to take into consideration that the binary format for the conversion can be: HEX, BASE64, or UTF-8. The default is the value of the BINARY_INPUT_FORMAT session parameter. If this parameter is not set, the default value is HEX.
Observations¶
Please keep in mind that the default output format for binary data types in BigQuery is ‘BASE64’ and in Snowflake ‘HEX’. You can use the BASE64_ENCODE function or set the BINARY_OUTPUT_FORMAT format if you want to view the data in BASE64 format.
The only formats supported by Snowflake are: HEX, BASE64, or UTF-8. For more information, please refer toBinary Input and Output in Snowflake.
Binary functions used to insert data into a values clause are not supported in Snowflake.
GEOGRAPHY¶
GEOGRAPHY data type and usages
Description¶
A collection of points, linestrings, and polygons, which is represented as a point set, or a subset of the surface of the Earth. For more information please refer to BigQuery GEOGRAPHY data type.
Success
Supported data type in Snowflake.
Sample Source Patterns¶
GEOGRAPHY output format¶
The default output format for geography data types in BigQuery is WKT (Well-Known Text) and in Snowflake WKB (Well-Known Binary). For this reason, when geography columns are selected, the ST_ASWKT function is automatically added. In addition, when all the columns of a table are selected and it contains a Geography column, the GEOGRAPHY_OUTPUT_FORMAT is set to WKT. This is in order to keep the default BigQuery format.
BigQuery¶
Snowflake¶
In case it is not added automatically and you want to see the data in WKT format, you can use the ST_ASWKT function or set the GEOGRAPHY_OUTPUT_FORMAT format.
Insert GEOGRAPHY data¶
To insert data in geography type columns, no function is needed, because Snowflake automatically detects that the data follows the WGS 84 standard.
Observations¶
Please keep in mind that the default output format for geography data types is WKT (Well-Known Text) and in Snowflake WKB (Well-Known Binary). You can use the ST_ASWKT function or set the GEOGRAPHY_OUTPUT_FORMAT format if you want to view the data in WKT format.
Geography functions used to insert data into a values clause are not needed in Snowflake.
Related EWIs¶
SSC-FDM-BQ0010: Geography function is not required in Snowflake.
INTERVAL¶
Interval data type and usages
Description¶
An INTERVAL object represents duration or amount of time, without referring to any specific point in time. There is no equivalent in Snowflake so it is transformed to Varchar (BigQuery Language Reference INTERVAL Data Type)
Syntax
Sample Source Patterns¶
Interval with a single DateTime part¶
BigQuery¶
Result¶
Snowflake¶
Result¶
Snowflake does not support the scenario where the Interval data type is queried directly, on the contrary when it is used as an operator for a given date its translation is done using an Interval constant (if possible).
Interval with a DateTime part range¶
BigQuery¶
Result¶
Snowflake¶
Result¶
The Interval value is transformed to a supported Snowflake format and then inserted as text inside the column. Since Snowflake does not support Interval as a data type, it is only supported in arithmetic operations. In order to use the value, it needs to be extracted and used as an Interval constant (if possible).
Interval as a Column data type¶
BigQuery¶
Result¶
ID |
interval_column |
|---|---|
1 |
2-11 28 0:0:0 |
2 |
2-11 28 16:15:14 |
3 |
0-11 28 16:15:14 |
4 |
0-0 0 0:15:14 |
Snowflake¶
Result¶
ID |
interval_column |
|---|---|
1 |
2y, 11mm, 28d |
2 |
2y, 11mm, 28d, 16h, 15m, 14s |
3 |
11mm, 28d, 16h, 15m, 14s |
4 |
15m, 14s |
In BigQuery the datetime_part follows the next canonical format:
Interval comparison¶
BigQuery¶
Snowflake¶
As is known, Snowflake only supports Interval as a data type in arithmetic operations, which is why the CURRENT_TIMESTAMP function is added to each operand to correctly support the comparison.
Known Issues¶
1. Only arithmetic operations are supported¶
Snowflake Intervals have several limitations. Only arithmetic operations between DATE or TIMESTAMP and Interval Constants are supported, every other scenario is not supported.
2. Working with signs in the Interval data type¶
In BigQuery, when the substring corresponding to the year-month is preceded by a sign (+ -), it affects both the year and the month. In a similar way, it works for the substring corresponding to the time, in this case, the following affects the hour, minute, and second. An example of this is shown below.
BigQuery¶
Snowflake¶
Related EWIs¶
SSC-EWI-0036: Data type converted to another data type.
SSC-EWI-0107: Interval Literal Not Supported In Current Scenario.
JSON¶
Json data type and usages
Description¶
Represents JSON, a lightweight data-interchange format. For more information please refer to BigQuery JSON data type.
Danger
JSON data type is not supported in Snowflake, currently transformed to VARIANT.
JSON Literals¶
For more information please refer to JSON Literals in BigQuery.
These literals are not supported in Snowflake, but instead the PARSE_JSON function can be used to convert the input expression to a json type. The only point to take into consideration is that this function cannot be used in the values clause in Snowflake, for this reason it is transformed to a subquery.
Sample Source Patterns¶
BigQuery¶
Snowflake¶
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 AI handles most implementation differences.
Note
Arguments that represent keys within the OBJECT_CONSTRUCT must be the original names of the target STRUCT. Any name specified within a STRUCT expression body will be replaced with the name found in the target STRUCT. Most of the data pattern examples below contain an example of a name that is replaced by the target name.
Sample Source Patterns¶
BigQuery¶
Snowflake¶
Insert INT Data Type to STRUCT column¶
BigQuery¶
Snowflake¶
Insert STRING Data Type to STRUCT column¶
BigQuery¶
Snowflake¶
Insert STRUCT Data Type to STRUCT column¶
BigQuery¶
Snowflake¶
Insert ARRAY Data Type to STRUCT column¶
BigQuery¶
Snowflake¶
Insert to selected STRUCT columns¶
BigQuery¶
Snowflake¶
Insert to STRUCT column tuple syntax¶
Warning
Translation of tuple syntax values is currently not supported.
BigQuery¶
Snowflake¶
Update STRUCT column¶
BigQuery¶
Snowflake¶
Update STRUCT column field¶
BigQuery¶
Snowflake¶
Select from STRUCT column¶
BigQuery¶
Snowflake¶
Select from STRUCT column tuple syntax¶
BigQuery¶
Snowflake¶
Create a view using an anonymous STRUCT definition¶
BigQuery¶
Snowflake¶
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.
BigQuery¶
Snowflake¶
Related EWIs¶
SSC-FDM-BQ0010: Struct converted to VARIANT. Some of its usages might have functional differences.
SSC-EWI-BQ0012: SnowConvert AI was unable to generate a correct OBJECT_CONSTRUCT parameter. Missing symbol information.
SSC-FDM-BQ0008: Where clause references a column of STRUCT type.
TIMESTAMP¶
Timestamp data type and usages
Description¶
A timestamp value represents an absolute point in time, independent of any time zone or convention such as daylight saving time (DST), with microsecond precision. For more information please refer to BigQuery Timestamp data type.
Grammar syntax¶
| Name | Range |
|---|---|
| TIMESTAMP | 0001-01-01 00:00:00 to 9999-12-31 23:59:59.999999 UTC |
Success
TIMESTAMP data type currently transformed to TIMESTAMP_TZ.
It is important to remark that BigQuery stores TIMESTAMP data in Coordinated Universal Time (UTC).
Sample Source Patterns¶
TIMESTAMP without time¶
BigQuery¶
Result¶
Snowflake¶
Result¶
TIMESTAMP with time zone¶
When the time zone is defined you need to use the CONVERT_TIMEZONE function to store the data in Coordinated Universal Time (UTC). Also the timezone name inside the timestamp literal is not supported by Snowflake, in that case it is necessary to use this function as well.