Ingestion script contract reference

Prev Next

This page lists what a data source template's scripts must return and what they can read: the column aliases for SQL ingestion scripts, the DataFrames for Python ingestion and profile scripts, how template parameters reach a script, how type names map to internal types, and the placeholders for profile SQL. For explanations and worked examples, see Metadata ingestion scripts: SQL templates and Metadata ingestion scripts: Python templates.

SQL ingestion scripts

A Database category template has three scripts. Each runs once per ingestion for the whole data source, in this order, and a level runs only if the one before it succeeded.

Schema script

Column Required Type Value
Name Yes Text Schema name.

Table script

Column Required Type Value
Schema Yes Text Schema of the table. Must match a Name from the schema script, or the row is skipped.
Name Yes Text Table or view name.
Type No Text Starts with V: view. Starts with T, blank or missing: table. Anything else fails the level.
ViewDefinition No Text View SQL. Leading and trailing white space is trimmed.

Column script

Column Required Type Value
Schema Yes Text Schema of the table.
Table Yes Text Table of the column. Must match a Schema and Name from the table script, or the row is skipped.
Name Yes Text Column name.
DataType Yes Text Type name as the platform reports it. Mapped to an internal type through the template's Data Types tab.
Sequence Yes Integer Position of the column in the table.
IsNullable No Yes/no Column allows nulls.
IsIdentity No Yes/no Identity or autoincrement column.
IsPrimaryKey No Yes/no Part of the primary key.
StringMaxLength No Integer Maximum length of a string column. On String columns, zero or less displays as (max).
NumericPrecision No Integer Precision of a numeric column.
NumericScale No Integer Scale of a numeric column.
DateTimePrecision No Integer Fractional seconds precision.
Comment No Text Column comment. Becomes the column's description in the catalog.

Rules for every level

Rule Detail
Column names Matched without regard to letter case: Name, name and NAME are the same. If two result columns have the same name, the last one is used.
Missing required column The level fails with Missing field: <name> or Missing fields: <list>, and the levels below it don't run.
Yes/no values true/false, any integer (0 is no, anything else is yes), and text starting with Y or T (yes) or N or F (no). YES/NO from information_schema work as they are. Empty is no.
Integer values A value that can't be converted is ignored, and the field keeps its default (0 for Sequence, empty for the rest).
Object names Must not be blank and must be unique ignoring letter case. Either problem fails the level.
Objects no longer returned Marked deleted: deactivated with their history kept, not removed.
Any other column Written to a catalog custom field at the same level when the column name matches the field's reference key (letter case ignored). Blank values are skipped. Columns that match no custom field are ignored.

Python ingestion script

A Script category template has one Combined Script. It runs after the connection's pre-execution script, in the same Python scope, and must leave these variables set:

Variable Required Columns
schema_dataframe Yes Same as the schema script
table_dataframe Yes Same as the table script
column_dataframe No Same as the column script

Each variable is a pandas DataFrame. Variable names are exact; column names follow the same rules as the SQL scripts, including custom field columns. A missing required variable fails the ingestion with The expected DataFrame variable table_dataframe wasn't set by the script. Text the script prints appears in the preview.

Template parameters

Every Python script a template runs (the pre-execution script, the Combined Script and profile scripts) gets each template parameter as a variable named by its reference key. There is no parameters dictionary.

Parameter type Python value
String str
Dropdown str
Secret str, decrypted
Integer int; 0 when the value isn't a whole number
Boolean bool

Data types

DataType values are matched to the entries on the template's Data Types tab, ignoring letter case; otherwise the whole name must match (NUMBER(38,0) doesn't match NUMBER). A column with no match is cataloged with no internal type. The eight internal types:

Internal type Value in template files and the API
Approximate Numeric ApproximateNumeric
Boolean/Logical Boolean
Date/Time DateTime
Exact Numeric ExactNumeric
Geospatial Geospatial
GUID Guid
String String
Other Other

A new Python template starts with bool, float, float64, int, int64, object and str mapped. Built-in mappings for SQL Server, Snowflake and PostgreSQL: Data type mappings.

Profile placeholders

Query profiles (Aggregate Formula, FROM, Grouping Key), calculation expressions and profile conditions can use these placeholders. Values are inserted as they are, so quote object names the way your platform needs.

Metadata

Placeholder Value
{{database.id}} Data source ID
{{database.name}} Database name on the data source's connection
{{database.key}} Data source reference key
{{database.server}} Server name on the data source's connection
{{schema.id}} Schema ID
{{schema.name}} Schema name
{{table.id}} Table ID
{{table.name}} Table name
{{table.type}} Table or View
{{column.id}} Column ID
{{column.name}} Column name
{{column.data_type}} Type name from the column script
{{column.mapped_type}} Internal type name, such as Exact Numeric or Boolean/Logical
{{column.string_max_length}} StringMaxLength from the column script
{{column.is_nullable}} IsNullable from the column script
{{column.is_primary_key}} IsPrimaryKey from the column script
{{column.is_identity}} IsIdentity from the column script
{{column.numeric_precision}} NumericPrecision from the column script
{{column.numeric_scale}} NumericScale from the column script
{{column.sequence}} Sequence from the column script

Column placeholders are available only to column-level profiles.

Profile values

Placeholder Value
{{table.prf.<reference_key>}} Result of a table-level profile on the same table, such as {{table.prf.record_count}}
{{column.prf.<reference_key>}} Result of a column-level profile on the same column, such as {{column.prf.distinct_count}}

Referencing a profile value makes that profile a prerequisite, so it runs first.

How a Query profile is assembled

select
<Aggregate Formula> AS CONTEXT_1,
<Aggregate Formula> AS CONTEXT_2,
<Grouping Key> AS GROUPING_KEY
<FROM text>
 group by <Grouping Key>

One aggregate is added per table or column in the batch. The FROM field must start with from. The Grouping Key line and the group by clause appear only when a grouping key is set, which array formats need.

Python profile scripts

Output

Variable Columns Holds
table_profile_dataframe schema_name, table_name, profile_reference_key, grouping_key, profile_value Table-level results
column_profile_dataframe schema_name, table_name, column_name, profile_reference_key, grouping_key, profile_value Column-level results
table_dataframe, column_dataframe Same as ingestion Catalog rows for the object, read only when Return Table Metadata Dataframe or Return Column Metadata Dataframe is selected on the profile script. The Windows Directory template uses column_dataframe to catalog the columns inside each file it profiles.

grouping_key is the group label for array profiles and empty for single values. A row that repeats the same object, reference key and grouping key fails the script with Duplicate table profile entries or Duplicate column profile entries.

Metadata variables

A profile script runs once per object at its Object Iteration Type (Per Schema, Per Table or Per Column) and receives dictionaries describing that object:

Variable Set for Main keys
datasource_metadata Every iteration level id, name (the data source name), key
schema_metadata Every iteration level id, name; tables (a list of table dictionaries) when iterating per schema
table_metadata Per Table and Per Column id, name, type; columns (a list of column dictionaries) when iterating per table
column_metadata Per Column id, name, data_type, mapped_type, is_nullable, sequence and the other column keys listed under Metadata

The Windows Directory template's file profile script reads schema_metadata["name"] and table_metadata["name"] to find the file it is profiling.

Error messages

Message Cause
Missing field: Sequence The script didn't return a required column.
Invalid TableType mapping (should be 'Table' or 'View') A Type value starts with a letter other than T or V, such as BASE TABLE.
The table names are not unique. Validatar does not support case-sensitive distinctions in metadata object names. Two rows name the same table, or names differ only in letter case. Schemas and columns give the same message for their level.
The following schema contains 1 table with an unsupported name A table row has a blank Name.
The expected DataFrame variable schema_dataframe wasn't set by the script. A Python ingestion script didn't set a required DataFrame.
One of the prerequisite profiles is not enabled for the related Data Source Template A profile set includes a profile whose prerequisite is disabled on the template.