Conformance vectors

The conformance vectors are JSON test cases that pin the standard dialect’s behaviour (§12). They live in the repository, in tests/vectors/, and tests/test_vectors.py runs every one; they are not part of the installed package.

File

Covers

grammar.json

§3: syntax, escaping, unknown functions, arity, static argument checks

typing.json

§8.1, §8.2: whole vs embedded values, missing values, keys

functions.json

§5: every function, month and DST edges, the clocks

variables.json

§6: declared variables, resolved when read; escaped overrides

context.json

Values in the context resolved when read: a path through a placeholder, cycles, context_verbatim, where an error is reported

secrets.json

§7: tenant scope, base64, missing secrets, resolve(strict=False)

sql.json

§8.3: literals, positions, lexer edge cases, secrets

protected.json

Protected fields: id, name, type, version (or a custom list) outside settings

verbatim.json

Verbatim paths: values taken as written, not parsed

tables.json

Table and value functions, on arrays of objects

lookup.json

lookup: a reference written as a call, a whole namespace (not tasks), the str and json formats

attribution.json

Errors name the reference at fault (reference) and the namespaces the part that failed reads (namespaces)

nested.json

Nested placeholders: values as arguments, never rescanned; missing values and coalesce; secrets, resolve(strict=False) and SQL; depth

examples.json

§13: every row of the contract’s examples table

Format

Each file is {"defaults": {...}, "vectors": [...]}. A vector is the defaults merged with its own fields (vector wins, shallow merge).

Field

Meaning

name

Unique description

mode

validate, resolve or resolve_sql. input is put in the context and resolved by its path; for resolve_sql that path is a sql path

input

The JSON value (a SQL string for resolve_sql). An error path is relative to it

tenant_id

The run’s tenant (resolve*)

namespaces

resolve*: namespace name to its values; a placeholder in a value is resolved when the value is read

context_verbatim

resolve*: paths (reference syntax, from the context’s root) whose values in namespaces are taken as written

strict

resolve: false to keep, as written, a placeholder the context cannot resolve yet; expected is then a template (default true)

verbatim

validate, resolve: paths (reference syntax, from the root of input) whose values are taken as written

sql

validate: paths (as verbatim) whose values are SQL text: a get_secret or secret call is sql_secret, a misplaced placeholder sql_position

protected

validate: the protected keys, replacing the default id, name, type, version

secrets

resolve*: vault key to the stored value

now

resolve*: the current time (a date function without at, and the _now functions)

expected

resolve*: the result

error

resolve*: {"code", "path", "reference", "namespaces"}; all but code optional. reference is the written reference or null; namespaces is sorted and covers the part that failed, not the whole placeholder

errors

validate: every {"code", "path"}, in document order

Rules the vectors pin beyond the contract text

  • Table functions take arguments as values, not only strings. A table is an array of objects; columns are the keys in first-seen order. get_column_as_list keeps each value once, in order: numbers equal by value (1 and 1.0 are one), a boolean is not a number, arrays and objects by content. dataframe_to_json_array writes compact JSON (, and : with no spaces, non-ASCII escaped, / not escaped). Results are plain JSON; null or blank arguments, references or literals, are passed as no value. Messages never include argument values.

  • Values in the context (context.json, variables.json) are resolved each time a placeholder reads them, with the same context, so one value can read another. A value that is one whole placeholder is that placeholder’s value (coalesce skips it when it has none); any other string, object, or array is walked like input, and its result is never rescanned. A path the provider cannot follow because a value on the way is a string is followed into that value’s result (variables.cfg.k with cfg holding @{lookup, owner.settings}). Reading a value again while it is being resolved is cycle, naming the value read again as reference; so is reading values inside one another more than 64 deep. An error inside a value names its place in the context as path (/variables/v/w) and its own placeholder. context_verbatim paths, and everything under them, are read as written, and nothing is followed through them.

  • Verbatim paths use the reference path syntax from the root of the input; an array item is named by its index without leading zeros. The value there is returned as written, keys included, and is not parsed. A path not in the input is ignored. validate still checks protected fields inside a verbatim value.

  • Blank means ASCII whitespace only: space, \t, \n, \r, \f, \v.

  • Grammar whitespace is exactly space, \t, \r, \n. Other spaces are part of a bare literal.

  • Numbers as text use Python’s repr: integral floats keep .0 (2.0), exponents look like 1e-07 and 1e+21; integers and floats stay apart.

  • A date function’s time (at, its last argument) is RFC 3339 with Z or an offset and at most six fractional digits; without it the function uses now.

  • Namespaces are open: any [A-Za-z_][A-Za-z0-9_]* name. validate never reports unknown_namespace; resolution does, for a namespace the context lacks. A bare argument name.path is a reference; other bare text (1.5, a-b.c) is a literal.

  • Path segments are [A-Za-z0-9_:-]+ (UUIDs, READ::POSTGRESQL), or a quoted string ('company.key', "client id", quote doubled to include it) for any other key. Namespace names stay [A-Za-z_][A-Za-z0-9_]* and are never quoted. A quote starts a segment only at the start of a reference or right after a dot; @{ inside it is text. Quoting changes only which characters a segment may hold, not its meaning: rows.'0' indexes a list exactly like rows.0, in every namespace.

  • Keys: a placeholder in an object key is rejected, so a key cannot contain @{.

  • Protected fields: the protected keys (id, name, type, version unless a vector’s protected replaces them) outside any settings key (whatever its value) are not parsed; any @{ in them, quoted or not, is one protected_field error per string or key. settings itself cannot be protected: Python refuses a protected list that includes it. A nested value is checked as a whole, keys included.

  • coalesce skips only absence: a provider’s “no value” (Python MissingValue), null, or blank. Any other provider failure is an error, not skipped; vectors cannot express provider failures, so unit tests cover them.

  • Not strict keeps object keys and the placeholders it cannot resolve yet byte for byte and writes each secret as @{secret, '…'}, with ' doubled. A placeholder with a get_secret or secret call nested in another call is not evaluated: each get_secret is rewritten in place and the placeholder written in normal form, so a later context records each secret itself. Unit tests also check that resolving the template gives what a single resolve of the input gives (for successful results; on bad input the error reported can differ), and that scrub removes a secret in its quote-doubled form too.

  • Quoted text: inside quotes @{ is text. A quoted text as the whole expression, @{'…'}, resolves to that text (blank is missing_value) and takes no arguments; it is the only way to write @{ as text. @@{x} is @ followed by the placeholder @{x}.

  • SQL lexing follows the Postgres lexer DuckDB uses. An identifier character is an ASCII letter, digit, _, $, or any non-ASCII character. $tag$ tags may contain non-ASCII characters. a1$$ is one identifier; 1$$ is a number followed by a dollar quote. When the text before $ or E' is ambiguous, the rest of the statement counts as quoted.

  • SQL glue: a placeholder must not touch an identifier character, a quote, ., or another placeholder, or follow &.

  • Timezones are checked statically only for clearly unknown names; the exact list depends on the tzdata version.

Changing behaviour

Any bug fix or behaviour change adds or updates a vector first, in the same change as the code. Adding a function changes the registry, the vectors, and the version together.