Data type mappings

Prev Next

The Data Types tab on a data source template maps each type name your ingestion script returns, such as nvarchar, NUMBER or timestamp with time zone, to one of Validatar's eight internal types. Profiling, the catalog and template test filters work from the internal type, so a column whose type isn't mapped is cataloged but skipped by every profile that is restricted to data types.

Data Types tab showing type mappings

The eight internal types

Internal type Value in template files and the API Typical platform types
Approximate Numeric ApproximateNumeric float, real, double precision
Boolean/Logical Boolean bit, boolean
Date/Time DateTime date, time, datetime2, TIMESTAMP_NTZ, interval
Exact Numeric ExactNumeric int, bigint, decimal, numeric, NUMBER, money
Geospatial Geospatial geography, geometry, point
GUID Guid uniqueidentifier, uuid
String String varchar, nvarchar, char, TEXT
Other Other varbinary, xml, VARIANT, jsonb

Dates, times and timestamps all map to Date/Time; there is no separate date-only or time-only type. Binary types map to Other.

What the internal type drives

Where What it does
Profiling A profile with Restrict data types set runs only on columns whose internal type is on its list. In the standard profiles, blank_count runs on String columns, min_date on Date/Time, and mean_numeric on Exact Numeric and Approximate Numeric. Columns with no mapping are skipped by all of these.
Profile SQL and conditions {{column.mapped_type}} returns the internal type's name, such as Exact Numeric or Boolean/Logical, so a profile can branch on it.
Catalog A column's page shows the internal type as Mapped Type and picks its headline profile results by it: minimum, maximum and mean for numeric columns, earliest and latest dates for Date/Time, blank count and most common value for the rest. String types show their length (nvarchar(20)), and Exact Numeric types with a scale show precision and scale (decimal(18,2)).
Template tests Metadata Driven template tests can filter columns on Column Mapped Type.

How a type name is matched

Ingestion compares the DataType value from the column script (or column_dataframe) with the names on the Data Types tab:

  • The comparison ignores letter case, so varchar, VARCHAR and VarChar all match one entry. Don't add two entries that differ only in case: the template won't import over itself again.
  • Otherwise the whole name must match. NUMBER(38,0) doesn't match NUMBER. Return the bare type name and send precision, scale and length in their own columns.
  • A name with no match is still cataloged with its raw type. It just gets no internal type.
  • Mappings apply at ingestion. After you add or change one, run ingestion on the data sources that use the template; each affected column gets its new internal type in a new version.

Add a mapping

  1. Open the template and go to the Data Types tab.
  2. Click Add Mapping.
  3. In Data Type, enter the type name exactly as the ingestion script returns it.
  4. In Mapped Type, pick the internal type.
  5. Click Save.

To find names that need a mapping, look at the column script's preview on a data source (Schema Metadata > Configure Ingestion SQL > Column Script > Preview Script) and compare its DataType values with the tab.

Built-in mappings

These are the mappings the built-in templates ship with. Use them as the starting point for a template on a similar platform.

SQL Server

Internal type Data types
Exact Numeric bigint, decimal, int, money, numeric, smallint, smallmoney, tinyint
Approximate Numeric float, real
String char, nchar, nvarchar, varchar
Date/Time date, datetime, datetime2, datetimeoffset, smalldatetime, time
Boolean/Logical bit
GUID uniqueidentifier
Geospatial geography, geometry
Other binary, cursor, hierarchyid, image, json, ntext, rowversion, sql_variant, table, text, timestamp, varbinary, vector, xml

Two things catch people out. The legacy text and ntext types map to Other, so String-only profiles such as blank_count skip them; remap them to String if you want those profiles. And timestamp on SQL Server is a row version, not a date, which is why it maps to Other.

The built-in column script reads the type with TYPE_NAME(c.user_type_id), so a column declared with an alias type (CREATE TYPE dbo.Flag FROM bit) arrives as Flag. Add a mapping for each alias type your databases use.

Snowflake

Internal type Data types
Exact Numeric BIGINT, BYTEINT, DECIMAL, INT, INTEGER, NUMBER, NUMERIC, SMALLINT, TINYINT
Approximate Numeric DOUBLE, DOUBLE PRECISION, FLOAT, FLOAT4, FLOAT8, REAL
String CHAR, CHARACTER, STRING, TEXT, VARCHAR
Date/Time DATE, DATETIME, TIME, TIMESTAMP, TIMESTAMP_LTZ, TIMESTAMP_NTZ, TIMESTAMP_TZ
Boolean/Logical BOOLEAN
Geospatial GEOGRAPHY, GEOMETRY
Other ARRAY, BINARY, MAP, OBJECT, VARBINARY, VARIANT, VECTOR

Snowflake's information_schema.columns reports every fixed-point column as NUMBER, every string column as TEXT and every floating-point column as FLOAT, so those entries carry most columns. NUMBER maps to Exact Numeric whatever its scale; the scale is kept separately in NumericScale.

PostgreSQL

Internal type Data types
Exact Numeric bigint, bigserial, decimal, int, int2, int4, int8, integer, money, numeric, serial, serial2, serial4, serial8, smallint, smallserial
Approximate Numeric double precision, float4, float8, real
String bit, bit varying, char, character, character varying, json, text, varbit, varchar
Date/Time date, interval, time, time with time zone, time without time zone, timestamp, timestamp with time zone, timestamp without time zone, timestamptz, timetz
Boolean/Logical bool, boolean
GUID uuid
Geospatial box, circle, line, lseg, path, point, polygon
Other bytea, cidr, inet, jsonb, macaddr, macaddr8, pg_lsn, pg_snapshot, tsquery, tsvector, txid_snapshot, xml

json maps to String and jsonb to Other. PostgreSQL's information_schema.columns reports array columns as ARRAY and enum and extension types (PostGIS included) as USER-DEFINED; neither is in the built-in list, so add them if you need those columns classified.

Python templates

A new Script category template starts with seven mappings for the type names pandas and Python report:

Internal type Data types
Boolean/Logical bool
Approximate Numeric float, float64
Exact Numeric int, int64
String object, str

Add any other names your script returns, such as datetime64[ns] or the JSON schema types an API reports.