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 |
|---|---|
|
§3: syntax, escaping, unknown functions, arity, static argument checks |
|
§8.1, §8.2: whole vs embedded values, missing values, keys |
|
§5: every function, month and DST edges, the clocks |
|
§6: declared variables, resolved when read; escaped overrides |
|
Values in the context resolved when read: a path through a placeholder, cycles, |
|
§7: tenant scope, base64, missing secrets, |
|
§8.3: literals, positions, lexer edge cases, secrets |
|
Protected fields: |
|
Verbatim paths: values taken as written, not parsed |
|
Table and value functions, on arrays of objects |
|
|
|
Errors name the reference at fault ( |
|
Nested placeholders: values as arguments, never rescanned; missing values and |
|
§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 |
|---|---|
|
Unique description |
|
|
|
The JSON value (a SQL string for |
|
The run’s tenant ( |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_listkeeps each value once, in order: numbers equal by value (1and1.0are one), a boolean is not a number, arrays and objects by content.dataframe_to_json_arraywrites compact JSON (,and:with no spaces, non-ASCII escaped,/not escaped). Results are plain JSON;nullor 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 (coalesceskips it when it has none); any other string, object, or array is walked likeinput, 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.kwithcfgholding@{lookup, owner.settings}). Reading a value again while it is being resolved iscycle, naming the value read again asreference; so is reading values inside one another more than 64 deep. An error inside a value names its place in the context aspath(/variables/v/w) and its own placeholder.context_verbatimpaths, 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.
validatestill 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 like1e-07and1e+21; integers and floats stay apart.A date function’s time (
at, its last argument) is RFC 3339 withZor an offset and at most six fractional digits; without it the function usesnow.Namespaces are open: any
[A-Za-z_][A-Za-z0-9_]*name.validatenever reportsunknown_namespace; resolution does, for a namespace the context lacks. A bare argumentname.pathis 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 likerows.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,versionunless a vector’sprotectedreplaces them) outside anysettingskey (whatever its value) are not parsed; any@{in them, quoted or not, is oneprotected_fielderror per string or key.settingsitself cannot be protected: Python refuses aprotectedlist that includes it. A nested value is checked as a whole, keys included.coalesceskips only absence: a provider’s “no value” (PythonMissingValue),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 aget_secretorsecretcall nested in another call is not evaluated: eachget_secretis 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 thatscrubremoves 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 ismissing_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$orE'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.