Properties
A query definition is a named statement bound to a data source.
On this page
These properties apply wherever the definition lives — inline in the project file, in other YAML files, or in any provider that returns rows (Excel, a database query, …); sources can be combined. In YAML they are keys; in a tabular source they are the columns of one row. See Lists.
What a query definition is for
A query definition pairs a statement with the data source it runs against and gives the pair a name. It is not a test and is never evaluated on its own. It has two uses:
- Metadata for test templates. A test whose
Metadataproperty names a query becomes a template: CAT runs that query and expands the template once per returned row. This is the only place in CAT where one definition refers to another by query name. - Saved queries in CAT Studio. The Queries page runs a query against any data source and shows the result, so the data can be inspected before a test is written against it. Queries saved there are query definitions in the project.
A test’s own First query and Second query are not query names. They hold the statement text itself, and they are not resolved against the query definitions in the project.
Properties
| Property | Also accepted as | Required | Meaning |
|---|---|---|---|
Name |
Query name |
yes | How a test template refers to this query in its Metadata property |
Query |
Query text |
for use as metadata | The statement, in whatever language the data source’s provider understands — SQL, DAX, a worksheet select |
Data source |
Data source name |
for use as metadata | Name of a data source definition in the same project |
Description |
— | no | Free text |
CAT loads a query definition that carries only a name; nothing is checked until the query is used. A test template that names a query with no statement, or with a data source the project does not define, fails when the project is opened — the error names the template, the query and every data source name that does exist.
Property names are matched by synonym and are not case sensitive. See Naming conventions. %NAME% in any value is replaced with the value of the environment variable NAME. See Environment variables.
Example
Queries:
- Name: all gates
Description: Every gate in the flights system, one row per gate.
Data source: FlightsSystem
Query: |
SELECT GATE_ID, GATE_NUMBER
FROM DIM.GATES
The project file key is Queries. It was previously called Named sets, and that name is still accepted.
To see this query drive a test template, see Templates.