SnowConvert AI - BigQuery - CREATE TABLE

Syntaxe grammaticale

CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] TABLE [ IF NOT EXISTS ]
table_name
[(
  column | constraint_definition[, ...]
)]
[DEFAULT COLLATE collate_specification]
[PARTITION BY partition_expression]
[CLUSTER BY clustering_column_list]
[OPTIONS(table_option_list)]
[AS query_statement]

Modèles d’échantillons de sources


DEFAULT COLLATE

BigQuery
CREATE TABLE table1 (
    col1 STRING 
) 
DEFAULT COLLATE 'und:ci';
Snowflake
CREATE TABLE table1 (
    col1 STRING
)
DEFAULT_DDL_COLLATION='und-ci';

Option de table des étiquettes

BigQuery
CREATE TABLE table1
(
  col1 INT,
  col2 DATE
)
OPTIONS(
  labels=[("org_unit", "development")]
);
Snowflake
CREATE TAG IF NOT EXISTS "org_unit";

CREATE TABLE table1
(
  col1 INT,
  col2 DATE
)
WITH TAG( "org_unit" = "development" )
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "bigquery",  "convertedOn": "04/09/2025",  "domain": "test" }}'
;

Option de table de description

BigQuery
CREATE TABLE table1
(
  col1 INT,
  col2 DATE
)
OPTIONS(
  description = 'My table comment'
);
Snowflake
CREATE TABLE table1
(
  col1 INT,
  col2 DATE
)
COMMENT = '{ "description": "My table comment", "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "bigquery",  "convertedOn": "04/09/2025",  "domain": "test" }}'
;

Option de table de description

BigQuery
CREATE TABLE table1
(
  col1 INT,
  col2 DATE
)
OPTIONS(
  friendly_name = 'Some_table'
);
Snowflake
CREATE TABLE table1
(
  col1 INT,
  col2 DATE
)
COMMENT = '{ "friendly_name": "Some_table", "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "bigquery",  "convertedOn": "04/09/2025",  "domain": "test" }}'
;

Problèmes connus

1. Options de table non prises en charge

Toutes les options de table ne sont pas prises en charge dans Snowflake, lorsqu’une option de table non prise en charge est rencontrée dans la clause OPTIONS, un EWI sera généré pour vous en avertir.

BigQuery

 CREATE TABLE table1
(
  col1 INT,
  col2 DATE
)
OPTIONS(
  expiration_timestamp=TIMESTAMP "2025-01-01 00:00:00 UTC",
  partition_expiration_days=1,
  description="a table that expires in 2025, with each partition living for 24 hours",
  labels=[("org_unit", "development")]
);

Snowflake

 CREATE TAG IF NOT EXISTS "org_unit";

CREATE TABLE table1
(
  col1 INT,
  col2 DATE
)
WITH TAG( "org_unit" = "development" )
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0001 - SNOWFLAKE DOES NOT SUPPORT THE OPTIONS: EXPIRATION_TIMESTAMP, PARTITION_EXPIRATION_DAYS. ***/!!!
OPTIONS(
  expiration_timestamp=TIMESTAMP "2025-01-01 00:00:00 UTC",
  partition_expiration_days=1
)
COMMENT = '{ "description": "a table that expires in 2025, with each partition living for 24 hours", "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "bigquery",  "convertedOn": "04/09/2025",  "domain": "test" }}'
;

2. Le micro-partitionnement est automatiquement géré par Snowflake

Snowflake effectue un partitionnement automatique des données. Le partitionnement défini par l’utilisateur n’est pas pris en charge.

BigQuery
 CREATE TABLE table1(
    transaction_id INT, 
    transaction_date DATE
)
PARTITION BY transaction_date;
Snowflake
 CREATE TABLE table1 (
    transaction_id INT,
    transaction_date DATE
)
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0002 - MICRO-PARTITIONING IS AUTOMATICALLY PERFORMED ON ALL SNOWFLAKE TABLES. ***/!!!
PARTITION BY transaction_date;

COLUMN DEFINITION

Syntaxe grammaticale

 column :=
  column_name column_schema

column_schema :=
   {
     simple_type
     | STRUCT<field_list>
     | ARRAY<array_element_schema>
   }
   [PRIMARY KEY NOT ENFORCED | REFERENCES table_name(column_name) NOT ENFORCED]
   [DEFAULT default_expression]
   [NOT NULL]
   [OPTIONS(column_option_list)]

simple_type :=
  { data_type | STRING COLLATE collate_specification }

field_list :=
  field_name column_schema [, ...]

array_element_schema :=
  { simple_type | STRUCT<field_list> }
  [NOT NULL]

Modèles d’échantillons de sources

Option Description

BigQuery
CREATE TABLE table1 (
  col1 VARCHAR(20) OPTIONS(description="A repeated STRING field")
);
Snowflake
CREATE TABLE table1 (
  col1 VARCHAR(20) COMMENT = 'A repeated STRING field'
);

COLLATE

BigQuery
CREATE TABLE table1 (
  col1 STRING COLLATE 'und:ci'
);
Snowflake
CREATE TABLE table1 (
  col1 STRING COLLATE 'und-ci'
);

Problèmes connus

1. Le mode d’arrondi n’est pas pris en charge

Snowflake ne prend pas en charge la spécification d’un mode d’arrondi par défaut sur les colonnes.

BigQuery

CREATE TABLE table1 (
  col1 STRING OPTIONS(rounding_mode = "ROUND_HALF_EVEN")
);

Snowflake

CREATE TABLE table1 (
    col1 STRING
    !!!RESOLVE EWI!!! /*** SSC-EWI-BQ0001 - SNOWFLAKE DOES NOT SUPPORT THE OPTIONS: ROUNDING_MODE. ***/!!!
    OPTIONS(
        rounding_mode = "ROUND_HALF_EVEN"
    )
)

EWIs connexes

  1. SSC-EWI-BQ0001: Snowflake ne prend pas en charge la clause d’options.

CREATE EXTERNAL TABLE

Description

Les tables externes permettent à BigQuery d’interroger des données stockées hors du stockage BigQuery. (Référence linguistique BigQuery SQL CREATE EXTERNAL TABLE)

Syntaxe

CREATE [ OR REPLACE ] EXTERNAL TABLE [ IF NOT EXISTS ] table_name
[(
  column_name column_schema,
  ...
)]
[WITH CONNECTION {connection_name | DEFAULT}]
[WITH PARTITION COLUMNS
  [(
      partition_column_name partition_column_type,
      ...
  )]
]
OPTIONS (
  external_table_option_list,
  ...
);

L’instruction CREATE EXTERNAL TABLE de BigQuery sera transformé en instruction CREATE EXTERNAL TABLE de Snowflake, cependant, cette transformation nécessite une intervention de l’utilisateur.

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:

Considérations importantes pour les transformations présentées dans cette page :

  • L’espace réservé @EXTERNAL_STAGE doit être remplacé par la zone de préparation externe créée après avoir suivi le guide précédent.

  • Il est supposé que la zone de préparation externe pointera vers la racine du compartiment. Il est important d’en tenir compte, car la clause PATTERN générée pour chaque table spécifie les chemins d’accès aux fichiers/dossiers en partant de la base du compartiment. Définir une zone de préparation externe pointant vers un emplacement différent dans le compartiment peut entraîner un comportement indésirable.

  • La clause AUTO_REFRESH = FALSE est générée pour éviter les erreurs, veuillez noter que l’actualisation automatique des métadonnées de table externe n’est valide que si votre fournisseur Cloud de compte Snowflake et le fournisseur de compartiment sont identiques et qu’une intégration de notification a été créée.

Modèles d’échantillons de sources

CREATE EXTERNAL TABLE avec liste de colonnes explicite

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
 CREATE OR REPLACE EXTERNAL TABLE test.Employees_test
(
  Employee_id INTEGER,
  Name STRING,
  Mail STRING,
  Position STRING,
  Salary INTEGER
)
OPTIONS(
  FORMAT='CSV',
  SKIP_LEADING_ROWS=1,
  URIS=['gs://sc_external_table_bucket/folder_with_csv/Employees.csv']
);
Snowflake
 CREATE OR REPLACE EXTERNAL TABLE test.Employees_test
(
  Employee_id INTEGER AS CAST(GET_IGNORE_CASE($1, 'c1') AS INTEGER),
  Name STRING AS CAST(GET_IGNORE_CASE($1, 'c2') AS STRING),
  Mail STRING AS CAST(GET_IGNORE_CASE($1, 'c3') AS STRING),
  Position STRING AS CAST(GET_IGNORE_CASE($1, 'c4') AS STRING),
  Salary INTEGER AS CAST(GET_IGNORE_CASE($1, 'c5') AS INTEGER)
)
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0015 - EXTERNAL TABLE REQUIRES AN EXTERNAL STAGE TO ACCESS gs://sc_external_table_bucket, DEFINE AND REPLACE THE EXTERNAL_STAGE PLACEHOLDER ***/!!!
LOCATION = @EXTERNAL_STAGE
AUTO_REFRESH = false
PATTERN = 'folder_with_csv/Employees.csv'
FILE_FORMAT = (TYPE = CSV SKIP_HEADER =1);

CREATE EXTERNAL TABLE sans liste de colonnes explicite

Lorsque la liste de colonnes n’est pas fournie, BigQuery détecte automatiquement le schéma des colonnes à partir de la structure du fichier. Pour reproduire ce comportement, SnowConvert AI générera une clause USING TEMPLATE qui utilise la fonction INFER_SCHEMA pour générer les définitions de colonnes.

Étant donné que la fonction INFER_SCHEMA nécessite un format de fichier pour fonctionner, SnowConvert AI générera un format de fichier temporaire à cette fin, ce format de fichier n’est requis que lors de l’exécution de l’instruction CREATE EXTERNAL TABLE et sera automatiquement détruit à la fin de la session.

BigQuery
 CREATE OR REPLACE EXTERNAL TABLE test.my_external_table_json
OPTIONS(
  FORMAT='JSON',
  URIS=['gs://sc_external_table_bucket/folder_with_json/Cars.jsonl']
);
Snowflake
CREATE OR REPLACE TEMPORARY FILE FORMAT SC_TEST_MY_EXTERNAL_TABLE_JSON_FORMAT
TYPE = JSON;

CREATE OR REPLACE EXTERNAL TABLE test.my_external_table_json USING TEMPLATE (
SELECT
  ARRAY_AGG(OBJECT_CONSTRUCT('COLUMN_NAME', COLUMN_NAME, 'TYPE', TYPE, 'NULLABLE', NULLABLE, 'EXPRESSION', EXPRESSION))
FROM
  TABLE(INFER_SCHEMA(LOCATION => '@EXTERNAL_STAGE/folder_with_json/Cars.jsonl', FILE_FORMAT => 'SC_TEST_MY_EXTERNAL_TABLE_JSON_FORMAT'))
)
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0015 - EXTERNAL TABLE REQUIRES AN EXTERNAL STAGE TO ACCESS gs://sc_external_table_bucket, DEFINE AND REPLACE THE EXTERNAL_STAGE PLACEHOLDER ***/!!!
LOCATION = @EXTERNAL_STAGE
AUTO_REFRESH = false
PATTERN = 'folder_with_json/Cars.jsonl'
FILE_FORMAT = (TYPE = JSON);

CREATE EXTERNAL TABLE avec plusieurs URIs

Lorsque plusieurs sources URIs sont spécifiés, ils seront joints dans le regex de la clause PATTERN dans Snowflake, les caractères génériques * utilisés seront transformés en .* équivalent dans Snowflake.

BigQuery
 CREATE OR REPLACE EXTERNAL TABLE test.multipleFilesTable
(
  Name STRING,
  Code STRING,
  Price NUMERIC,
  Expiration_date DATE
)

OPTIONS(
  format="CSV",
  skip_leading_rows = 1,
  uris=['gs://sc_external_table_bucket/folder_with_csv/Food.csv', 'gs://sc_external_table_bucket/folder_with_csv/other_products/*']
);
Snowflake
 CREATE OR REPLACE EXTERNAL TABLE test.multipleFilesTable
(
  Name STRING AS CAST(GET_IGNORE_CASE($1, 'c1') AS STRING),
  Code STRING AS CAST(GET_IGNORE_CASE($1, 'c2') AS STRING),
  Price NUMERIC AS CAST(GET_IGNORE_CASE($1, 'c3') AS NUMERIC),
  Expiration_date DATE AS CAST(GET_IGNORE_CASE($1, 'c4') AS DATE)
)
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0015 - EXTERNAL TABLE REQUIRES AN EXTERNAL STAGE TO ACCESS gs://sc_external_table_bucket, DEFINE AND REPLACE THE EXTERNAL_STAGE PLACEHOLDER ***/!!!
LOCATION = @EXTERNAL_STAGE
AUTO_REFRESH = false
PATTERN = 'folder_with_csv/Food.csv|folder_with_csv/other_products/.*'
FILE_FORMAT = (TYPE = CSV SKIP_HEADER = 1);

Clause WITH CONNECTION

La clause WITH CONNECTION est supprimée car les informations de connexion sont déjà fournies à Snowflake à l’aide de l’intégration de stockage.

BigQuery
 CREATE EXTERNAL TABLE test.awsTable
  WITH CONNECTION `aws-us-east-1.s3-read-connection`
  OPTIONS (
    format="JSON",
    uris=["s3://s3-bucket/json_files/example.jsonl"]
);
Snowflake
CREATE OR REPLACE TEMPORARY FILE FORMAT SC_TEST_AWSTABLE_FORMAT
TYPE = JSON;

CREATE EXTERNAL TABLE test.awsTable USING TEMPLATE (
SELECT
  ARRAY_AGG(OBJECT_CONSTRUCT('COLUMN_NAME', COLUMN_NAME, 'TYPE', TYPE, 'NULLABLE', NULLABLE, 'EXPRESSION', EXPRESSION))
FROM
  TABLE(INFER_SCHEMA(LOCATION => '@EXTERNAL_STAGE/json_files/example.jsonl', FILE_FORMAT => 'SC_TEST_AWSTABLE_FORMAT'))
)
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0015 - EXTERNAL TABLE REQUIRES AN EXTERNAL STAGE TO ACCESS s3://s3-bucket, DEFINE AND REPLACE THE EXTERNAL_STAGE PLACEHOLDER ***/!!!
LOCATION = @EXTERNAL_STAGE
AUTO_REFRESH = false
PATTERN = 'json_files/example.jsonl'
FILE_FORMAT = (TYPE = JSON);

Options de table prises en charge

Les options de table externe suivantes sont prises en charge dans Snowflake et transformées par SnowConvert AI:

  • FORMAT

  • ENCODING

  • SKIP_LEADING_ROWS

  • FIELD_DELIMITER

  • COMPRESSION

BigQuery
CREATE OR REPLACE EXTERNAL TABLE test.songs_test
(
  Name STRING,
  Release_date INTEGER,
  Songs INT,
  Genre STRING
)
OPTIONS(
  FORMAT='CSV',
  ENCODING='UTF-8',
  SKIP_LEADING_ROWS=1,
  FIELD_DELIMITER='|',
  COMPRESSION='GZIP',
  URIS=['gs://sc_external_table_bucket/folder_with_csv/Albums.csv']
);
Snowflake
CREATE OR REPLACE EXTERNAL TABLE test.songs_test
(
  Name STRING AS CAST(GET_IGNORE_CASE($1, 'c1') AS STRING),
  Release_date INTEGER AS CAST(GET_IGNORE_CASE($1, 'c2') AS INTEGER),
  Songs INT AS CAST(GET_IGNORE_CASE($1, 'c3') AS INT),
  Genre STRING AS CAST(GET_IGNORE_CASE($1, 'c4') AS STRING)
)
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0015 - EXTERNAL TABLE REQUIRES AN EXTERNAL STAGE TO ACCESS gs://sc_external_table_bucket, DEFINE AND REPLACE THE EXTERNAL_STAGE PLACEHOLDER ***/!!!
LOCATION = @EXTERNAL_STAGE
AUTO_REFRESH = false
PATTERN = 'folder_with_csv/Albums.csv'
FILE_FORMAT = (TYPE = CSV
  ENCODING= 'UTF8' SKIP_HEADER =1
  FIELD_DELIMITER='|'
  COMPRESSION= GZIP);

Problèmes connus

1. CREATE EXTERNAL TABLE sans liste de colonnes explicite et format de fichier CSV

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.

Un FDM est généré pour notifier que l’en-tête ne peut pas être analysé et que renommer manuellement les colonnes est nécessaire pour préserver les noms.

BigQuery

 CREATE OR REPLACE EXTERNAL TABLE test.my_external_table_csv
OPTIONS(
  FORMAT='CSV',
  URIS=['gs://sc_external_table_bucket/folder_with_csv/Employees.csv']
);

Snowflake

CREATE OR REPLACE TEMPORARY FILE FORMAT SC_TEST_MY_EXTERNAL_TABLE_CSV_FORMAT
TYPE = CSV
SKIP_HEADER = 1;

CREATE OR REPLACE EXTERNAL TABLE test.my_external_table_csv
--** SSC-FDM-BQ0005 - PARSING THE CSV HEADER IS NOT SUPPORTED IN EXTERNAL TABLES, COLUMNS MUST BE RENAMED TO MATCH THE ORIGINAL NAMES **
USING TEMPLATE (
SELECT
  ARRAY_AGG(OBJECT_CONSTRUCT('COLUMN_NAME', COLUMN_NAME, 'TYPE', TYPE, 'NULLABLE', NULLABLE, 'EXPRESSION', EXPRESSION))
FROM
  TABLE(INFER_SCHEMA(LOCATION => '@EXTERNAL_STAGE/folder_with_csv/Employees.csv', FILE_FORMAT => 'SC_TEST_MY_EXTERNAL_TABLE_CSV_FORMAT'))
)
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0015 - EXTERNAL TABLE REQUIRES AN EXTERNAL STAGE TO ACCESS gs://sc_external_table_bucket, DEFINE AND REPLACE THE EXTERNAL_STAGE PLACEHOLDER ***/!!!
LOCATION = @EXTERNAL_STAGE
AUTO_REFRESH = false
PATTERN = 'folder_with_csv/Employees.csv'
FILE_FORMAT = (TYPE = CSV SKIP_HEADER = 1);

2. Tables externes référençant des sources Google Drive

Snowflake ne prend pas en charge la lecture de données à partir de fichiers hébergés dans Google Drive, un FDM sera généré pour le notifier et demander que les fichiers soient téléchargés vers le compartiment et accessibles via la zone de préparation externe.

La clause PATTERN contiendra les espaces réservés auto-générés FILE_PATH0, FILE_PATH1, …, FILE_PATHN, qui doivent être remplacés par le chemin d’accès du fichier/dossier après le déplacement des fichiers vers l’emplacement externe.

BigQuery
 CREATE OR REPLACE EXTERNAL TABLE test.my_external_table_drive_test
OPTIONS(
  FORMAT='JSON',
  URIS=['https://drive.google.com/open?id=someFileId']
);
Snowflake
 CREATE OR REPLACE TEMPORARY FILE FORMAT SC_TEST_MY_EXTERNAL_TABLE_DRIVE_TEST_FORMAT
TYPE = JSON;

CREATE OR REPLACE EXTERNAL TABLE test.my_external_table_drive_test USING TEMPLATE (
SELECT
  ARRAY_AGG(OBJECT_CONSTRUCT('COLUMN_NAME', COLUMN_NAME, 'TYPE', TYPE, 'NULLABLE', NULLABLE, 'EXPRESSION', EXPRESSION))
FROM
  --** SSC-FDM-BQ0008 - THE INFER_SCHEMA FUNCTION REQUIRES A FILE PATH WITHOUT WILDCARDS TO GENERATE THE TABLE TEMPLATE, REPLACE THE FILE_PATH PLACEHOLDER WITH IT **
  TABLE(INFER_SCHEMA(LOCATION => '@EXTERNAL_STAGE/FILE_PATH', FILE_FORMAT => 'SC_TEST_MY_EXTERNAL_TABLE_DRIVE_TEST_FORMAT'))
)
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0015 - EXTERNAL TABLE REQUIRES AN EXTERNAL STAGE TO ACCESS A EXTERNAL LOCATION, DEFINE AND REPLACE THE EXTERNAL_STAGE PLACEHOLDER ***/!!!
LOCATION = @EXTERNAL_STAGE
AUTO_REFRESH = false
--** 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 **
PATTERN = 'FILE_PATH0'
FILE_FORMAT = (TYPE = JSON);

3. Tables externes avec le format de fichier GOOGLE_SHEETS

Snowflake ne prend pas en charge Google Sheets en tant que format de fichier. Cependant, sa structure est similaire à celle des fichiers CSV, qui sont pris en charge par 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.

Les feuilles de Google étant stockées dans Google Drive, il serait nécessaire de charger les fichiers comme CSV vers l’emplacement externe et de spécifier les chemins d’accès aux fichiers dans la clause PATTERN, comme mentionné dans la question précédente.

BigQuery
 CREATE OR REPLACE EXTERNAL TABLE test.spreadsheetTable
(
  Name STRING,
  Code INTEGER,
  Price INTEGER,
  Expiration_date DATE
)
OPTIONS(
  format="GOOGLE_SHEETS",
  skip_leading_rows = 1,
  uris=['https://docs.google.com/spreadsheets/d/someFileId/edit?usp=sharing']
);
Snowflake
 --** SSC-FDM-BQ0007 - THE GOOGLE_SHEETS FORMAT IS NOT SUPPORTED IN SNOWFLAKE. CSV FILE TYPE IS USED AS A WORKAROUND. **
CREATE OR REPLACE EXTERNAL TABLE test.spreadsheetTable
(
  Name STRING AS CAST(GET_IGNORE_CASE($1, 'c1') AS STRING),
  Code INTEGER AS CAST(GET_IGNORE_CASE($1, 'c2') AS INTEGER),
  Price INTEGER AS CAST(GET_IGNORE_CASE($1, 'c3') AS INTEGER),
  Expiration_date DATE AS CAST(GET_IGNORE_CASE($1, 'c4') AS DATE)
)
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0015 - EXTERNAL TABLE REQUIRES AN EXTERNAL STAGE TO ACCESS A EXTERNAL LOCATION, DEFINE AND REPLACE THE EXTERNAL_STAGE PLACEHOLDER ***/!!!
LOCATION = @EXTERNAL_STAGE
AUTO_REFRESH = false
--** 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 **
PATTERN = 'FILE_PATH0'
FILE_FORMAT = (TYPE = CSV SKIP_HEADER = 1);

4. Tables externes avec formats de fichier non pris en charge

Snowflake prend en charge les formats BigQuery suivants :

BigQuery

Snowflake

AVRO

AVRO

CSV
GOOGLE_SHEETS

CSV

NEWLINE_DELIMITED_JSON
JSON

JSON

ORC

ORC

PARQUET

PARQUET

Les autres formats seront marqués comme non pris en charge.

BigQuery
 CREATE OR REPLACE EXTERNAL TABLE test.backup_restore_table
OPTIONS (
  format = 'DATASTORE_BACKUP',
  uris = ['gs://backup_bucket/backup_folder/*']
);
Snowflake
 !!!RESOLVE EWI!!! /*** SSC-EWI-BQ0013 - EXTERNAL TABLE DATA FORMAT NOT SUPPORTED IN SNOWFLAKE ***/!!!
CREATE OR REPLACE EXTERNAL TABLE test.backup_restore_table
OPTIONS (
  format = 'DATASTORE_BACKUP',
  uris = ['gs://backup_bucket/backup_folder/*']
);

**5. Tables externes partitionnées Hive

Snowflake ne prend pas en charge les tables externes partitionnées Hive, la clause WITH PARTITION COLUMNS sera marquée comme non prise en charge.

BigQuery
CREATE EXTERNAL TABLE test.CustomHivePartitionedTable
WITH PARTITION COLUMNS (
  field_1 STRING,
  field_2 INT64)
OPTIONS (
  uris = ['gs://sc_external_table_bucket/folder_with_parquet/*'],
  format = 'PARQUET',
  hive_partition_uri_prefix = 'gs://sc_external_table_bucket/folder_with_parquet',
  require_hive_partition_filter = false);
Snowflake
CREATE OR REPLACE TEMPORARY FILE FORMAT SC_TEST_CUSTOMHIVEPARTITIONEDTABLE_FORMAT
TYPE = PARQUET;

CREATE EXTERNAL TABLE test.CustomHivePartitionedTable USING TEMPLATE (
SELECT
  ARRAY_AGG(OBJECT_CONSTRUCT('COLUMN_NAME', COLUMN_NAME, 'TYPE', TYPE, 'NULLABLE', NULLABLE, 'EXPRESSION', EXPRESSION))
FROM
  --** SSC-FDM-BQ0008 - THE INFER_SCHEMA FUNCTION REQUIRES A FILE PATH WITHOUT WILDCARDS TO GENERATE THE TABLE TEMPLATE, REPLACE THE FILE_PATH PLACEHOLDER WITH IT **
  TABLE(INFER_SCHEMA(LOCATION => '@EXTERNAL_STAGE/FILE_PATH', FILE_FORMAT => 'SC_TEST_CUSTOMHIVEPARTITIONEDTABLE_FORMAT'))
)
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0015 - EXTERNAL TABLE REQUIRES AN EXTERNAL STAGE TO ACCESS gs://sc_external_table_bucket, DEFINE AND REPLACE THE EXTERNAL_STAGE PLACEHOLDER ***/!!!
LOCATION = @EXTERNAL_STAGE
AUTO_REFRESH = false
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0014 - HIVE PARTITIONED EXTERNAL TABLES ARE NOT SUPPORTED IN SNOWFLAKE ***/!!!
WITH PARTITION COLUMNS (
  field_1 STRING,
  field_2 INT64)
PATTERN = 'folder_with_parquet/.*'
FILE_FORMAT = (TYPE = PARQUET)
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0001 - SNOWFLAKE DOES NOT SUPPORT THE OPTIONS: HIVE_PARTITION_URI_PREFIX, REQUIRE_HIVE_PARTITION_FILTER. ***/!!!
OPTIONS(
  hive_partition_uri_prefix = 'gs://sc_external_table_bucket/folder_with_parquet',
  require_hive_partition_filter = false
);

**6. Table externe sans liste de colonnes et aucun fichier valide URI pour la fonction INFER_SCHEMA **

La fonction INFER_SCHEMA requiert un paramètre LOCATION qui spécifie le chemin d’accès à un fichier ou à un dossier qui sera utilisé pour construire les colonnes de la table, cependant, ce chemin ne prend pas en charge les expressions regex, ce qui signifie que le caractère générique * n’est pas pris en charge.

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
CREATE OR REPLACE EXTERNAL TABLE test.my_external_table_json2
OPTIONS(
  FORMAT='JSON',
  URIS=['gs://sc_external_table_bucket/folder_with_json/*']
);
Snowflake
CREATE OR REPLACE TEMPORARY FILE FORMAT SC_TEST_MY_EXTERNAL_TABLE_JSON2_FORMAT
TYPE = JSON;

CREATE OR REPLACE EXTERNAL TABLE test.my_external_table_json2 USING TEMPLATE (
SELECT
  ARRAY_AGG(OBJECT_CONSTRUCT('COLUMN_NAME', COLUMN_NAME, 'TYPE', TYPE, 'NULLABLE', NULLABLE, 'EXPRESSION', EXPRESSION))
FROM
  --** SSC-FDM-BQ0008 - THE INFER_SCHEMA FUNCTION REQUIRES A FILE PATH WITHOUT WILDCARDS TO GENERATE THE TABLE TEMPLATE, REPLACE THE FILE_PATH PLACEHOLDER WITH IT **
  TABLE(INFER_SCHEMA(LOCATION => '@EXTERNAL_STAGE/FILE_PATH', FILE_FORMAT => 'SC_TEST_MY_EXTERNAL_TABLE_JSON2_FORMAT'))
)
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0015 - EXTERNAL TABLE REQUIRES AN EXTERNAL STAGE TO ACCESS gs://sc_external_table_bucket, DEFINE AND REPLACE THE EXTERNAL_STAGE PLACEHOLDER ***/!!!
LOCATION = @EXTERNAL_STAGE
AUTO_REFRESH = false
PATTERN = 'folder_with_json/.*'
FILE_FORMAT = (TYPE = JSON);

7. Options de table non prises en charge

Toute autre option de table non mentionnée dans le modèle Options de table prises en charge sera marquée comme non prise en charge.

BigQuery
CREATE OR REPLACE EXTERNAL TABLE dataset.CsvTable
(
  x INTEGER,
  y STRING
)
OPTIONS (
  format = 'CSV',
  uris = ['gs://bucket/example.csv'],
  field_delimiter = '|',
  max_bad_records = 5
);
Snowflake
CREATE OR REPLACE EXTERNAL TABLE dataset.CsvTable
(
  x INTEGER AS CAST(GET_IGNORE_CASE($1, 'c1') AS INTEGER),
  y STRING AS CAST(GET_IGNORE_CASE($1, 'c2') AS STRING)
)
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0015 - EXTERNAL TABLE REQUIRES AN EXTERNAL STAGE TO ACCESS gs://bucket, DEFINE AND REPLACE THE EXTERNAL_STAGE PLACEHOLDER ***/!!!
LOCATION = @EXTERNAL_STAGE
AUTO_REFRESH = false
PATTERN = 'example.csv'
FILE_FORMAT = (TYPE = CSV
  field_delimiter = '|')
!!!RESOLVE EWI!!! /*** SSC-EWI-BQ0001 - SNOWFLAKE DOES NOT SUPPORT THE OPTIONS: MAX_BAD_RECORDS. ***/!!!
OPTIONS(
  max_bad_records = 5
);

EWIs connexes

  1. SSC-EWI-BQ0013: Le format des données de table externe n’est pas pris en charge dans Snowflake

  2. SSC-EWI-BQ0014: Les tables externes partitionnées Hive ne sont pas prises en charge dans Snowflake

  3. SSC-EWI-BQ0015: External table requires an external stage to access an external location, define and replace the EXTERNAL_STAGE placeholder

  4. SSC-FDM-BQ0004: La fonction INFER_SCHEMA requiert un chemin de fichier sans caractères génériques pour générer le modèle de table et remplacer l’espace réservé FILE_PATH par celui-ci.

  5. SSC-FDM-BQ0005: L’analyse de l’en-tête CSV n’est pas prise en charge dans les tables externes. Les colonnes doivent être renommées pour correspondre aux noms d’origine.

  6. SSC-FDM-BQ0006: La lecture à partir de Google Drive n’est pas prise en charge dans Snowflake ; chargez les fichiers vers l’emplacement externe et remplacez les espaces réservés FILE_PATH

  7. SSC-FDM-BQ0007: The GOOGLE_SHEETS format is not supported in Snowflake. CSV file type is used as a workaround.

CREATE TABLE CLONE

Syntaxe grammaticale

CREATE TABLE [ IF NOT EXISTS ]
destination_table_name
CLONE source_table_name [FOR SYSTEM_TIME AS OF time_expression]
...
[OPTIONS(table_option_list)]

Modèles d’échantillons de sources

FOR SYSTEM TIME AS OF

BigQuery
CREATE TABLE my_clone_table
CLONE some_table_name2
FOR SYSTEM_TIME AS OF TIMESTAMP "2025-01-01 00:00:00 UTC";
Snowflake
CREATE TABLE my_clone_table
CLONE some_table_name2 AT (TIMESTAMP => TIMESTAMP "2025-01-01 00:00:00 UTC");

::{note} L’option LABELS dans les instructions CREATE TABLE CLONE ne sont pas transformées en TAGs parce que les TAGs de la table source sont copiées, elles ne peuvent pas être modifiées pendant la copie de la table. La transformation des autres options de table est la même que celle spécifiée pour l’instruction CREATE TABLE.

CREATE TABLE COPY

Grammar syntax

CREATE [ OR REPLACE ] TABLE [ IF NOT EXISTS ] table_name
COPY source_table_name
...
[OPTIONS(table_option_list)]

Sample Source Patterns

Cas général

CREATE TABLE CLONE dans Snowflake est fonctionnellement équivalent à CREATE TABLE COPY.

Code d’entrée
BigQuery
CREATE TABLE newtable
COPY sourceTable;
Snowflake
CREATE TABLE newtable CLONE sourceTable;

Note

L’option LABELS dans les instructions CREATE TABLE COPY ne sont pas transformées en TAGs parce que les TAGs de la table source sont copiées, elles ne peuvent pas être modifiées pendant la copie de la table. La transformation des autres options de table est la même que celle spécifiée pour l’instruction CREATE TABLE.

CREATE TABLE LIKE

Syntaxe grammaticale

CREATE [ OR REPLACE ] TABLE [ IF NOT EXISTS ]
table_name
LIKE [[project_name.]dataset_name.]source_table_name
...
[OPTIONS(table_option_list)]

Succès

L’instruction CREATE TABLE LIKE est entièrement pris en charge par Snowflake.

Note

L’option LABELS dans les instructions CREATE TABLE LIKE ne sont pas transformées en TAGs parce que les TAGs de la table source sont copiées, elles ne peuvent pas être modifiées pendant la copie de la table. La transformation des autres options de table est la même que celle spécifiée pour l’instruction CREATE TABLE.

CREATE TABLE SNAPSHOT

Syntaxe grammaticale

CREATE SNAPSHOT TABLE [ IF NOT EXISTS ] table_snapshot_name
CLONE source_table_name
[FOR SYSTEM_TIME AS OF time_expression]
[OPTIONS(snapshot_option_list)]

Modèles d’échantillons de sources

Cas général

Le mot-clé Snapshot (instantané) est supprimé dans Snowflake, transformant la table en CREATE TABLE CLONE.

Les deux différences entre les instantanés et les clones sont les suivantes : les instantanés ne sont pas modifiables et ont généralement une date d’expiration. Les dates d’expiration ne sont pas prises en charge ; ceci est traité comme spécifié pour les options CREATE TABLE.

BigQuery
CREATE SNAPSHOT TABLE mytablesnapshot
CLONE mytable;
Snowflake
CREATE TABLE mytablesnapshot CLONE mytable;

FOR SYSTEM TIME AS OF

BigQuery
CREATE SNAPSHOT TABLE IF NOT EXISTS my_snapshot_table2
CLONE some_table_name2
FOR SYSTEM_TIME AS OF TIMESTAMP "2025-01-01 00:00:00 UTC";
Snowflake
CREATE TABLE IF NOT EXISTS my_snapshot_table2
CLONE some_table_name2 AT (TIMESTAMP => TIMESTAMP "2025-01-01 00:00:00 UTC");

Note

L’option LABELS dans les instructions CREATE TABLE COPY ne sont pas transformées en TAGs parce que les TAGs de la table source sont copiées, elles ne peuvent pas être modifiées pendant la copie de la table.

La transformation des autres options de table est la même que celle spécifiée pour l’instruction CREATE TABLE.