SnowConvert AI - BigQuery - CREATE TABLE¶
Grammar syntax¶
Sample Source Patterns¶
DEFAULT COLLATE¶
BigQuery¶
Snowflake¶
Labels table option¶
BigQuery¶
Snowflake¶
Description table option¶
BigQuery¶
Snowflake¶
Description table option¶
BigQuery¶
Snowflake¶
Known Issues¶
1. Unsupported table options
Not all table options are supported in Snowflake, when an unsupported table option is encountered in the OPTIONS clause, an EWI will be generated to warn about this.
BigQuery¶
Snowflake¶
2. Micro-partitioning is automatically managed by Snowflake
Snowflake performs automatic partitioning of data. User defined partitioning is not supported.
BigQuery¶
Snowflake¶
COLUMN DEFINITION¶
Grammar syntax¶
Sample Source Patterns¶
Description option¶
BigQuery¶
Snowflake¶
COLLATE¶
BigQuery¶
Snowflake¶
Known Issues¶
1. Rounding mode not supported
Snowflake does not support specifying a default rounding mode on columns.
BigQuery¶
Snowflake¶
Related EWIs¶
SSC-EWI-BQ0001: Snowflake does not support the options clause.
CREATE EXTERNAL TABLE¶
Description¶
External tables let BigQuery query data that is stored outside of BigQuery storage. (BigQuery SQL Language Reference CREATE EXTERNAL TABLE)
Syntax
The CREATE EXTERNAL TABLE statement from BigQuery will be transformed to a CREATE EXTERNAL TABLE statement from Snowflake, however, this transformation requires user intervention.
To complete the transformation performed by SnowConvert AI, it is necessary to define a Storage Integration, a External Stage and (optional) Notification Integration that have access to the external source were files are located. Please refer to the following guides on how to set up the connection for each provider:
Important considerations for the transformations shown in this page:
The @EXTERNAL_STAGE placeholder must be replaced with the external stage created after following the previous guide.
It is assumed that the external stage will point to the root of the bucket. This is important to consider because the PATTERN clause generated for each table specifies the file/folder paths starting at the base of the bucket, defining the external stage pointing to a different location in the bucket might produce undesired behavior.
The
AUTO_REFRESH = FALSEclause is generated to avoid errors, please note that automatic refresh of external table metadata is only valid if your Snowflake account cloud provider and the bucket provider are the same and a Notification Integration was created.
Sample Source Patterns¶
CREATE EXTERNAL TABLE with explicit column list¶
When the column list is provided, SnowConvert AI will automatically generate the AS expression column options for each column to extract the file values.
BigQuery¶
Snowflake¶
CREATE EXTERNAL TABLE without explicit column list¶
When the column list is not provided, BigQuery automatically detects the schema of the columns from the file structure. To replicate this behavior, SnowConvert AI will generate a USING TEMPLATE clause that makes use of the INFER_SCHEMA function to generate the column definitions.
Since the INFER_SCHEMA function requires a file format to work, SnowConvert AI will generate a temporary file format for this purpose, this file format is only required when running the CREATE EXTERNAL TABLE statement and it will be automatically dropped when the session ends.
BigQuery¶
Snowflake¶
CREATE EXTERNAL TABLE with multiple URIs¶
When multiple source URIs are specified, they will be joined in the regex of the PATTERN clause in Snowflake, the wildcard * characters used will be transformed to its .* equivalent in Snowflake.
BigQuery¶
Snowflake¶
WITH CONNECTION clause¶
The WITH CONNECTION clause is removed because the connection information is already provided to Snowflake using the Storage Integration.
BigQuery¶
Snowflake¶
Supported table options¶
The following external table options are supported in Snowflake and transformed by SnowConvert AI:
FORMAT
ENCODING
SKIP_LEADING_ROWS
FIELD_DELIMITER
COMPRESSION
BigQuery¶
Snowflake¶
Known Issues¶
1. CREATE EXTERNAL TABLE without explicit column list and CSV file format
Currently, Snowflake external tables do not support parsing the header of CSV files. When an external table with no explicit column list and CSV file format is found, SnowConvert AI will produce the SKIP_HEADER file format option to avoid runtime errors, however, this will cause the table column names to have the autogenerated names c1, c2, …, cN.
An FDM is generated to notify that the header can not be parsed and that manually renaming the columns is necessary to preserve the names.
BigQuery¶
Snowflake¶
2. External tables referencing Google Drive sources
Snowflake does not support reading data from files hosted in Google Drive, an FDM will be generated to notify about this and request that the files are uploaded to the bucket and accessed through the external stage.
The PATTERN clause will hold autogenerated placeholders FILE_PATH0, FILE_PATH1, …, FILE_PATHN that should be replaced with the file/folder path after the files were moved to the external location.
BigQuery¶
Snowflake¶
3. External tables with the GOOGLE_SHEETS file format
Snowflake does not support Google Sheets as a file format, however, its structure is similar to CSV files, which are supported by Snowflake.
When SnowConvert AI detects an external table using the GOOGLE_SHEETS format, it will produce an external table with the CSV file format instead.
Since Google Sheets are stored in Google Drive, it would be necessary to upload the files as CSV to the external location and specify the file paths in the PATTERN clause, just as mentioned in the previous issue.
BigQuery¶
Snowflake¶
4. External tables with unsupported file formats
Snowflake supports the following BigQuery formats:
BigQuery |
Snowflake |
|---|---|
AVRO |
AVRO |
CSV |
CSV |
NEWLINE_DELIMITED_JSON |
JSON |
ORC |
ORC |
PARQUET |
PARQUET |
Other formats will be marked as not supported.
BigQuery¶
Snowflake¶
5. Hive partitioned external tables
Snowflake does not support hive partitioned external tables, the WITH PARTITION COLUMNS clause will be marked as not supported.
BigQuery¶
Snowflake¶
6. External table without columns list and no valid file URI for the INFER_SCHEMA function
The INFER_SCHEMA function requires a LOCATION parameter that specifies the path to a file or folder that will be used to construct the table columns, however, this path does not support regex, meaning that the wildcard * character is not supported.
When the table has no columns, SnowConvert AI will check all URIS to find one that does not use wildcards and use it in the INFER_SCHEMA function, when no URI meets such criteria an FDM and FILE_PATH placeholder will be generated, the placeholder has to be replaced with the path of one of the files referenced by the external table to generate the table columns.
BigQuery¶
Snowflake¶
7. Unsupported table options
Any other table option not mentioned in the Supported table options pattern will be marked as not supported.
BigQuery¶
Snowflake¶
Related EWIs¶
SSC-EWI-BQ0013: External table data format not supported in snowflake
SSC-EWI-BQ0014: Hive partitioned external tables are not supported in snowflake
SSC-EWI-BQ0015: External table requires an external stage to access an external location, define and replace the EXTERNAL_STAGE placeholder
SSC-FDM-BQ0004: The INFER_SCHEMA function requires a file path without wildcards to generate the table template, replace the FILE_PATH placeholder with it
SSC-FDM-BQ0005: Parsing the CSV header is not supported in external tables, columns must be renamed to match the original names
SSC-FDM-BQ0006: Reading from Google Drive is not supported in Snowflake, upload the files to the external location and replace the FILE_PATH placeholders
SSC-FDM-BQ0007: The GOOGLE_SHEETS format is not supported in Snowflake. CSV file type is used as a workaround.
CREATE TABLE CLONE¶
Grammar syntax¶
Sample Source Patterns¶
FOR SYSTEM TIME AS OF¶
BigQuery¶
Snowflake¶
::{note} The LABELS option in CREATE TABLE CLONE statements are not transformed into TAGs because the TAGs of the source table are copied, they cannot be changed during the copy of the table. Transformation of other table options are the same as specified for the CREATE TABLE statement.
CREATE TABLE COPY
Grammar syntax
Sample Source Patterns
General case
CREATE TABLE CLONE in Snowflake is functionally equivalent to CREATE TABLE COPY.
Input Code
BigQuery
Snowflake
Note
The LABELS option in CREATE TABLE COPY statements are not transformed into TAGs because the TAGs of the source table are copied, they cannot be changed during the copy of the table. Transformation of other table options are the same as specified for the CREATE TABLE statement.
CREATE TABLE LIKE¶
Grammar syntax¶
Success
CREATE TABLE LIKE is fully supported by Snowflake.
Note
The LABELS option in CREATE TABLE LIKE statements are not transformed into TAGs because the TAGs of the source table are copied, they cannot be changed during the copy of the table. Transformation of other table options are the same as specified for the CREATE TABLE statement.
CREATE TABLE SNAPSHOT¶
Grammar syntax¶
Sample Source Patterns¶
General case¶
The Snapshot keyword is removed in Snowflake, transforming the table into a CREATE TABLE CLONE.
The two differences between snapshot and clones are that snapshots are not editable and usually have an expiration date. Expiration dates are not supported, this is handled as specified for the CREATE TABLE statement unsupported options.
BigQuery¶
Snowflake¶
FOR SYSTEM TIME AS OF¶
BigQuery¶
Snowflake¶
Note
The LABELS option in CREATE TABLE COPY statements are not transformed into TAGs because the TAGs of the source table are copied, they cannot be changed during the copy of the table.
Transformation of other table options are the same as specified for the CREATE TABLE statement.