Entered data
The few values a test expects, such as twelve month numbers, two status codes or one year, are typed into the test itself.
A test often compares a query with a handful of values somebody knows to be right. Those values need no database and no file. Name EnteredData as the data source and write the rows where the query would be: the first line holds the column names, every further line is one row.
- Name
- Revenue of 2024 per region did not change
- First data source
- DWH
- First query
SELECT RegionID, Region, SUM(Amount) AS Revenue FROM Fact.Sales WHERE YEAR(InvoiceDate) = 2024 GROUP BY RegionID, Region- Second data source
- EnteredData
- Second query
RegionID, Region, Revenue 3, North, 1250300.50 7, South, 980120.00 12, East, 2210000.75 105, West, 455000.10- Expectation
- sets match
- Key
- RegionID
- Sort data
- true
- Tolerance
- 0.01
Tests:
- Name: Revenue of 2024 per region did not change
First data source: DWH
First query: |
SELECT RegionID, Region, SUM(Amount) AS Revenue
FROM Fact.Sales
WHERE YEAR(InvoiceDate) = 2024
GROUP BY RegionID, Region
Second data source: EnteredData
Second query: |
RegionID, Region, Revenue
3, North, 1250300.50
7, South, 980120.00
12, East, 2210000.75
105, West, 455000.10
Expectation: sets match
Key: RegionID
Sort data: true
Tolerance: 0.01
EnteredData is not declared under Data sources:; every project has it. CAT reads the text into typed columns, here a whole number, a text and a decimal number, so Key and Sort data work as they do against a database.
Why the form is strict
The form is narrow on purpose: one separator, one form of a number, one form of a date (yyyy-MM-dd). CAT has an opinion here and says so.
The reason is ambiguity. 3.4.2026 is the third of April on one machine and the fourth of March on another, and 1,5 is one and a half here and fifteen there. An entered text reads the same on every machine, every time.
It is made for simple cases, a few values that fit on a screen, and it does not try to be clever. What fits no rule is text or an Error, never a guess: a text like 90,30;10, a tab and "a gets no smart reading.
Who needs more (another form of a date, other literals, an expression, a row that holds only a NULL) writes the expected rows as a query against another data source and compares the two with Sets match or Contains. That provider’s own parser and its rules for literals apply there. Two ways, in this order:
- a query against a data source the project already has: a
VALUESlist orSELECT … UNION ALL SELECT …in its dialect; - a DuckDB@1 data source, which needs no server but does need a database file.
How to write the text
The first line that is not empty holds the column names. Every further line that is not empty is one row.
ID, Name
1, Anna
A comma separates the values, and nothing else does. The decimal separator is a dot.
ID, Rate
1, 1.5
Spaces and tabs around a value are not part of it, so these two rows are the same:
1, Anna
1,Anna
Empty lines are ignored wherever they stand: before the column names, between the rows, after the last row. A line that holds only spaces and tabs is empty too.
There are no settings and no comments. A # is a character like any other.
Quotes
A value that starts with " or ' is a quoted value. The two quotes work the same way.
-
It runs to the next quote of the same kind. Everything in between belongs to the value: commas, line breaks, spaces at the edges, the other kind of quote.
ID, Name 1, "Smith, John" -
The same quote inside is written twice.
'it''s' "say ""hi""" -
After the closing quote only spaces and tabs may follow before the comma or the end of the line.
-
A quote that is not the first character of the value is an ordinary character:
O'Brien,5". A text that really starts with a quote is written inside the other kind:"'tis". -
A quoted value is always text, and it makes its whole column text. So
"0"and'0'are text, and0is a number. -
A column name may be quoted as well. That says nothing about the type of the column.
Empty values
Nothing between two commas, or nothing after the last comma, is NULL. Two quotes with nothing between them, "" or '', are the empty text.
ID, Note
1,
2, ""
In a text of one column a row that holds only a NULL cannot be entered: it would be an empty line, and empty lines are ignored.
How the values are typed
A column has one type, decided from all its values. The first row of this table that holds wins.
Every value of the column that is not NULL is |
The column is |
|---|---|
| (at least one value is quoted) | text |
(every value is NULL, or there is no row) |
text |
true or false, in any case |
true/false |
| a whole number that fits 64 bits | a whole number |
| a whole number or a decimal number, of at most 28 digits | a decimal number, every decimal kept |
| a date | a date |
| anything else | text, as written |
- A whole number is digits with an optional
-in front and no leading zero (0itself is fine).007,+5,1e5,1 000and(5)are text. - A decimal number is a whole number followed by a dot and at least one digit:
0.5,-3.25,1250300.50..5and1.are text. - 28 digits counts every digit of the value, before and after the dot. One value with more makes the column text.
- A date is
yyyy-MM-dd, alone or followed by a space orTand a time:HH:mm,HH:mm:ss, orHH:mm:sswith a dot and one to seven digits. It must be a real date and a real time, hours 00 to 23.2026-04-03T08:00:00Z,2026-04-03 24:00,2026-02-30,3.4.2026,4/3/2026and2026-04are text. - A time alone (
08:30) and a GUID are text.
A value in quotes is always text. Enter a code that is made of digits in quotes when the column it is compared with is text, and bare when that column is a number: a Key needs compatible types on the two sides, and Sort data orders text and numbers differently. See Order and key.
What ends with Error
A text that breaks a rule ends the test, or the command, with Error. A wrong value is never repaired and never skipped. N is the line, counted from 1 with the empty lines and the lines inside a quoted value counted too; the column number, the name and the counts below are examples.
| What is wrong | Message |
|---|---|
| the text is empty, or holds only empty lines | Entered data is empty. The first line holds the column names. |
| a column with no name | Entered data, line N: column 3 has no name. |
| two columns with the same name, ignoring case | Entered data, line N: the column name 'ID' is used twice. |
| a row with more or fewer values than there are column names | Entered data, line N: 3 values, but the header has 2 columns. |
a quote that is opened and not closed; N is the line where it opens |
Entered data, line N: the quote " is opened and never closed. |
| a tab inside a value that is not quoted | Entered data, line N: a tab inside a value. Values are separated by commas; a value that holds a tab is written in quotes. |
| text after a closing quote | Entered data, line N: text follows the closing quote ". A quote inside a quoted value is written twice. |
A table copied from Excel is tab-separated and is refused with the message about the tab; the values are separated by commas. A decimal comma splits the value in two, so 1, 1,5 under two column names is a row with one value too many.
Where the message shows depends on what ran:
- a test with
set is empty,set is not emptyorset row count, and a query run on its own, carry it in their message; - a test with
sets matchorcontainssays only which query failed to open (Failed to open the second query.); the sentence above is then in the log,catcli run -l error.
Row order
The entered rows are compared in the order they are typed. A test that should not depend on that order says Sort data: true, as with any other data source. See Order and key.
Where it works
- In a test, as the first or the second data source, with every expectation.
- In a query definition. A query with
Data source: EnteredDataholds its rows inQuery. - In a query run on its own:
catcli exec -d EnteredData -c "<text>",Invoke-CatCommandof the PowerShell module. CAT Studio has nothing to run for such a query, so Run Query is off: the rows are typed or pasted in the grid that replaces the editor. - As the metadata of a test template, through such a query definition — see In a test template.
%NAME% is replaced inside the text as in every other value. See Environment variables.
Take the rows from a query
The rows need not be typed. What catcli exec prints as CSV for a query can be pasted in as it is, and it reads back as the same rows, numbers as numbers, dates as dates and text as text: run the query against the system that is known to be right, paste the result as the expected rows.
catcli exec -d DWH -c "SELECT RegionID, Region, SUM(Amount) AS Revenue FROM Fact.Sales GROUP BY RegionID, Region" --format csv
Two kinds of result do not come back the same:
- A result of one column that holds a
NULL. That row is printed as an empty line, and empty lines are ignored. - Types entered data does not have come back as text: a time, a GUID, a date printed with a time zone offset, and a floating-point number printed with an exponent (
1E-05).
In a test template
A short hand-typed list can drive a template: the query the template names in Metadata has Data source: EnteredData, and CAT makes one test per entered row.
Queries
- Name
- regions
- Data source
- EnteredData
- Query
RegionID, Region 3, North 7, South 12, East
Tests
- Name
- Region %Region% has invoices
- Metadata
- regions
- Data source
- DWH
- Query
- SELECT * FROM Fact.Sales WHERE RegionID = %RegionID%
- Expectation
- set is not empty
Queries:
- Name: regions
Data source: EnteredData
Query: |
RegionID, Region
3, North
7, South
12, East
Tests:
- Name: Region %Region% has invoices
Metadata: regions
Data source: DWH
Query: SELECT * FROM Fact.Sales WHERE RegionID = %RegionID%
Expectation: set is not empty
A %COLUMN% placeholder gets the typed value turned into text, as for a database column: an entered 2026-04-03 is a date and does not arrive as written. A value that must arrive as written is entered in quotes, '2026-04-03'.
When to use something else
- More rows than fit on a screen, or rows several tests share: a CSV file with Csv@2. Nothing limits the size of an entered text; it is simply not what it is for.
- Another delimiter, a decimal comma, a pinned type: a CSV file with Csv@2 as well, which has settings for them.
- Values that need a provider’s own literals or an expression: a query against a data source, as Why the form is strict says.
Which expectation says what
With the entered rows as the second set:
| The query returns | Expectation |
|---|---|
| exactly these values | sets match |
| only these values, not necessarily all of them | second contains first |
| at least these values | contains |
The directions of contains are on Contains.
The name is built in
EnteredData resolves in every project without a line under Data sources:, and it is not listed among the project’s data sources: catcli ping does not test it, and catcli ping -d EnteredData answers that it is built in. EnteredData is a data source name, one word: Entered Data or entered_data do not resolve, but the case does not matter, so entereddata does. CAT Studio shows the name with a space, Entered data, and writes EnteredData into the project file when you pick it.
A data source the project declares under that name, in any case, takes its place: tests and queries that name it then go to the declared one.
A project file still needs Data sources:, or a list of data sources, to open. A project that uses nothing but entered data writes Data sources: [].
Related
- Test properties · Query properties
- Order and key · Tolerance
- Csv@2 — for more rows, shared rows and other formats.