• Start

From other databases

Migrating from Snowflake

How to map existing data and concepts from Snowflake to SurrealDB

This page shows how Snowflake data types map to their SurrealQL equivalents, then explains how to load Snowflake tables into SurrealDB with the Surreal Sync tool.

The following chart shows Snowflake data types along with the equivalent or near-equivalent SurrealQL data type for each. Surreal Sync reads values through the Snowflake SQL REST API, which returns every cell as a string together with the column's logical type, and converts each one using that type.

Snowflake Data TypeSurrealDB MappingNotes
BOOLEANbool
NUMBER / INT / INTEGER / BIGINTintWhole numbers (scale 0) that fit a 64-bit integer
NUMBER(p,s) / DECIMAL / NUMERICnumberValues with a scale, or larger than a 64-bit integer, keep their precision and scale as a decimal
FLOAT / REAL / DOUBLEfloat (f64)Double-precision floating point
VARCHAR / STRING / TEXT / CHARstring
DATEdatetimeStored as days since the Unix epoch, converted to a datetime at midnight UTC
TIMEdatetimeSeconds since midnight
TIMESTAMP_NTZ / DATETIMEdatetimeNo timezone; taken as the given wall-clock instant
TIMESTAMP_LTZ / TIMESTAMP_TZ / TIMESTAMPdatetimeTimezone-aware; the absolute instant is preserved as UTC
VARIANT / OBJECTobjectParsed from the stored JSON document
ARRAYarrayParsed from the stored JSON array
BINARY / VARBINARYbytesHex-decoded to raw bytes

Any column whose logical type is not listed above is preserved as a string rather than failing the import.

Surreal Sync can read tables from a Snowflake database and write them to SurrealDB.

Note

The Snowflake source is ingestion-only. It performs a single full snapshot of the selected tables and does not support incremental synchronisation or change data capture. There is no durable cursor, so an interrupted run cannot be resumed part-way; re-run the command to start again.

Rows are read one Snowflake result partition at a time and written in batches, so a large table does not need to fit in memory.

Surreal Sync connects to Snowflake through the SQL REST API using key-pair (JWT) authentication. Before running an import:

  1. Generate an unencrypted PKCS#8 RSA key pair. Encrypted private keys are not supported yet.

  2. Register the public key on the Snowflake user that Surreal Sync will authenticate as:

    ALTER USER my_user SET RSA_PUBLIC_KEY='MIIBIjANBgkq...';
  3. Make sure that user has a role able to read the target database and schema, and a virtual warehouse to run the queries.

Keep the private key file accessible to Surreal Sync and pass its path with --private-key-path.

surreal-sync from snowflake \
  --account myorg-myaccount \
  --user my_user \
  --private-key-path ./rsa_key.p8 \
  --warehouse COMPUTE_WH \
  --database MY_DB \
  --schema PUBLIC \
  --to-namespace my_namespace \
  --to-database my_database \
  --surreal-endpoint ws://localhost:8000 \
  --surreal-username root \
  --surreal-password root

When --tables is omitted, every base table in the schema is imported (views and temporary tables are skipped). Each table becomes a table of the same name in SurrealDB, and each row becomes a record. Snowflake upper-cases unquoted identifiers, so table and column names arrive upper-cased.

Most connection options also read from an environment variable, which is useful for keeping credentials out of shell history.

OptionEnvironment variableRequiredDescription
--accountSNOWFLAKE_ACCOUNTYesAccount identifier as used in the host <account>.snowflakecomputing.com, for example myorg-myaccount or xy12345.us-east-1.
--userSNOWFLAKE_USERYesUser whose key pair is registered for JWT authentication.
--private-key-pathSNOWFLAKE_PRIVATE_KEY_PATHYesPath to the unencrypted PKCS#8 private key PEM file.
--private-key-passphraseSNOWFLAKE_PRIVATE_KEY_PASSPHRASENoPassphrase for an encrypted key. Not supported yet; setting it returns an error.
--warehouseSNOWFLAKE_WAREHOUSEYesVirtual warehouse used to run the queries.
--databaseSNOWFLAKE_DATABASEYesDatabase to read from.
--schemaSNOWFLAKE_SCHEMANoSchema within the database. Defaults to PUBLIC.
--roleSNOWFLAKE_ROLENoRole to assume for the session.
--tablesNoComma-separated list of tables to import. When omitted, all base tables in the schema are imported.
--id-columnsNoComma-separated columns forming the SurrealDB record ID. See Record IDs.
--transforms-configNoPath to a TOML file describing a transform pipeline. Omit to import rows unchanged.
--to-namespaceYesTarget SurrealDB namespace.
--to-databaseYesTarget SurrealDB database.

The --surreal-endpoint, --surreal-username, --surreal-password, --batch-size, and --dry-run options are shared with the other Surreal Sync sources. Use --dry-run to read and convert rows without writing to SurrealDB.

Snowflake primary keys are optional and often absent, so the record ID for each row depends on --id-columns:

  • Omitted: a sequential per-table integer is generated. It is deterministic within a run but not stable across re-runs, so prefer explicit ID columns when you need stable IDs.

  • A single column: the value becomes the record ID, as an integer when it parses as one and otherwise as a string.

  • Several columns: the values are joined with : into a string ID.

When ID columns are given, they are used only for the record ID and are not repeated as fields on the record. Column names are matched case-insensitively.

Was this page helpful?