Skip to contentManaged Kafka is live: Apache Kafka on AWS for half the cost of MSK

Using Artie

Artie's typing library

How Artie picks a destination type for each column and when a new column reaches the destination. Covers numbers, JSON, arrays and timestamps.

Artie’s typing library is part of Artie Transfer, the service that writes to your destination. In its benchmarks it detects the type of an integer, boolean or float 1.7 to 1.9 times faster than Go’s reflect package.

When schema changes reach the destination

A new column reaches the destination once Artie knows its type. Where the type comes from depends on the source.

SourceWhere the type comes fromA column that holds only NULLs
Relational, for example PostgreSQL and MySQLThe source column’s typeAdded with the next write, even when every value is NULL
Non-relational, for example DynamoDB and MongoDBThe first value that isn’t NULLAdded when the first value that isn’t NULL arrives

For a non-relational source, Artie waits for a real value so that it never picks a type from incomplete data.

Artie adds every column that exists in the source and is missing from the destination, unless the table’s column inclusion or exclusion list leaves it out. For how tables are created and columns are dropped, see Schema evolution.

A new source table joins a running pipeline only when Auto-replicate new tables is on. Artie checks for new tables every weekday at 6 AM Pacific Time by default. See Automatically add new tables.

Data type handling

Artie settles each column’s type in this order:

  1. Initial type detection: For a new column, Artie uses the source schema. Without a source schema, it uses the first value that isn’t NULL.
  2. Type preservation: Once the column exists in the destination, the destination’s type is the source of truth.
  3. Data type conversion: When the source and destination types differ, Artie converts each value to the destination’s type.

To change a column’s type, create or alter the column in the destination. Artie keeps the destination’s type.

Failed conversions

When a value can’t be converted to the column’s type, the write fails with an error. In these cases, Artie writes a different value instead of failing:

CaseWhat Artie writes
A string too long for its column on Redshift, Snowflake, Oracle, MySQL or Microsoft SQL Server__artie_exceeded_value
A JSON object too large for its column on Redshift or Snowflake{"key":"__artie_exceeded_value"}
A value that doesn’t fit, with Truncate exceeded values onRedshift trims the string to fit. BigQuery trims a decimal to the column’s scale.
A spatial value Snowflake can’t convertNULL in a new row. An update keeps the stored value.
An invalid value, with an option only Artie can turn onNULL. On Snowflake this covers bad timestamps, numbers and booleans; on BigQuery, bad timestamps.
MongoDB NaN, Infinity or -Infinity, or a date outside years 1 to 9999NULL
A DynamoDB number with more digits than a double holdsThe number, rounded to a double

Artie emails an alert for replication errors unless Disable alert emails is on for the pipeline. For help with a conversion error, email [email protected].

Numbers

For a relational source, the number type comes from the source column: integer, float, double, or decimal with its precision and scale.

For MongoDB, the type comes from the value:

  • 5 → Integer
  • "5" → String
  • 5.0 → Float

Three source values are stored differently from how the source holds them:

Source valueStored asWhy
MongoDB Decimal128StringNot every destination holds a Decimal128 without losing precision
MongoDB NaN, Infinity and -InfinityNULLThe value is not a finite number
DynamoDB number (N)DoubleDynamoDB has one number type for integers and decimals

A decimal that is wider than the destination’s decimal type is stored as a string. The limit for each destination is listed under Variable numeric.

JSON objects

Artie stores a JSON object as it appears in the source, with no flattening or transformation.

A Snowflake column that holds a nested JSON object from the source
JSON object preservation in Snowflake example

Without a source schema, a string that holds a valid JSON object or array is also typed as JSON.

Arrays

Artie stores both of these array shapes as arrays:

  • Simple arrays
  • Nested arrays with objects

A simple array in Snowflake:

A Snowflake column that holds a simple array

An array with nested objects in Snowflake:

A Snowflake column that holds an array with nested objects

Timestamps, dates, and times

Artie parses a string into a date, time or timestamp when the source schema or the destination column has that type. It reads 22 string layouts:

TypeLayoutsExample layouts
Timestamp, standard layouts17RFC 3339 with up to nanosecond precision, RFC 822, RFC 850, RFC 1123, ANSI C, Unix date, Ruby date
Timestamp with no time zone offset22006-01-02T15:04:05.999999999, 2006-01-02 15:04:05.999999999
Date12006-01-02
Time215:04:05.999999, 15:04:05.999999Z07:00

A layout matches only when formatting the parsed value returns the original string, so parsing never drops fractional seconds. Times of day use Artie’s own wrapper around Go’s time.Time and are written with microsecond precision.

A MongoDB date with a year before 1 or after 9999 is stored as NULL.

Variable numeric

A variable numeric column A variable numeric column is a numeric data type without precision or scale specified. in Postgres stores any number of digits in each value, up to the implementation limit Up to 131072 digits before the decimal point; up to 16383 digits after the decimal point. That exceeds the numeric type of most destinations, so those destinations get a string column to keep every digit.

Oracle, CockroachDB, Amazon Keyspaces and Snowflake sources send variable numeric columns too, such as an Oracle NUMBER declared without precision and scale, or a Snowflake DECFLOAT. The rules below apply to them the same way.

The column type Artie creates depends on the destination:

DestinationVariable numeric columnDecimal with a fixed precision becomes a string when
SnowflakeSTRINGPrecision is above 38
DatabricksSTRINGPrecision is above 38
RedshiftTEXTPrecision is above 38
Microsoft SQL ServerVARCHAR(MAX)Precision is above 38
IcebergSTRINGPrecision is above 38
ClickHouseSTRINGPrecision is above 76
MotherDuckTEXT, or DOUBLE with DOUBLE for variable numerics onPrecision is above 38
BigQueryNUMERIC, or BIGNUMERIC with BIGNUMERIC for variable numerics onPrecision or scale is outside the BIGNUMERIC range
PostgreSQLNUMERICNever
OracleNUMBERPrecision is above 38
MySQLDECIMAL(65, 5)Precision is above 65 or scale is above 30

The two settings appear for PostgreSQL, Oracle, CockroachDB, Amazon Keyspaces and Snowflake sources. In pipeline setup, they are under Advanced options on the destination step. On an existing pipeline, they are under Advanced settings on the destination tab. Their labels there are Use BIGNUMERIC for variable numeric columns and Use DOUBLE for variable numeric columns.

MySQL DECIMAL(65, 5), BigQuery NUMERIC and Oracle NUMBER have a fixed size, so a variable numeric value can hold more digits than the column:

  • MySQL rounds the value to 5 decimal places.
  • BigQuery NUMERIC holds 9 decimal places. Truncate exceeded values trims the rest, and BIGNUMERIC holds 38.
  • Oracle NUMBER holds 38 significant digits.

To use a different type, alter the destination column. Artie keeps the destination’s type.

  • Schema evolution: how Artie creates tables and adds or drops columns.
  • MongoDB: typing for mixed-type fields, nested fields, and the Cast all columns to string setting.

Need help?

Email [email protected] with questions this page doesn’t cover.

Was this page helpful?