Skip to main content

Support for UUID data types in Spanner targets

Spanner Writer and Spanner PG Dialect Writer can write to UUID columns and to UUID array columns: UUID and ARRAY<UUID> in the GoogleSQL dialect, and uuid and uuid[] in the PostgreSQL dialect. No configuration is required. The writer detects UUID and UUID array columns from the target table schema and converts incoming values automatically.

Writing UUID values

A UUID column can be written from any of the following source values:

  • UUIDs in string form, for example from an Oracle VARCHAR2 or CHAR column

  • native UUID values, for example from a PostgreSQL uuid column

  • Oracle RAW(16) values

A UUID column can be used as a primary key and can be specified in the KeyColumns option of the Tables property.

Writing UUID arrays

UUID array columns accept array values in either native array form or string notation. Null and empty arrays are supported. The validation rules and troubleshooting guidance in Support for ARRAY data types in Spanner targets apply to UUID arrays as they do to other array types.

Spanner does not support array columns as primary keys. If you specify a UUID array column in the KeyColumns option of the Tables property, the application terminates.

Preserve Source Transaction Boundary and upsert

UUID and UUID array columns have no additional restrictions when used with Preserve Source Transaction Boundary (see Using Preserve Source Transaction Boundary with Spanner targets) or with Execute Insert As Update and Execute Update As Insert (see Upsert support in Spanner targets).

DDL replication

When CDDL Action is Process (see Handling schema evolution), UUID columns are handled as follows.

UUID columns:

  • For CREATE TABLE and ADD COLUMN, when the source column is a PostgreSQL uuid, SQL Server uniqueidentifier, or Snowflake UUID, the target column is created as UUID (GoogleSQL) or uuid (PostgreSQL dialect). Columns from other sources are created using the standard type mappings: for example, an Oracle RAW(16) column is created as BYTES or bytea, not as a UUID column.

  • DROP COLUMN is supported.

UUID array columns:

  • For CREATE TABLE and ADD COLUMN, when the source is PostgreSQL or Snowflake, the target column is created as a string column rather than as a native array column. When the source is any other database, the application terminates.

  • DROP COLUMN is supported.