Share the test data as CSV, one directory per dataset - #912
Merged
Conversation
Oracle reads the empty string as NULL, so an empty city district became '-', and countrylanguage.isofficial is written 1/0.
A column names its kind in the CSV header and each dialect renders it.
Its table is schema-qualified, which the CREATE TABLE regex did not match.
An input task runs once per aggregated project, so newDataset opts out.
phdoerfler
force-pushed
the
feat/generated-test-data
branch
from
August 27, 2026 23:39
b8dff60 to
2bdea6c
Compare
milessabin
approved these changes
Aug 28, 2026
milessabin
left a comment
Member
There was a problem hiding this comment.
This is great stuff! LGTM!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This PR rewrites the test data .sql files into .csv and adds build-time code which recreates the previous .sql files customised for all three flavours of SQL currently supported by Grackle. It also groups these data files into named datasets. Previously, the dialect directories contained a flat list of .sql files. They still end up getting loaded into the same database. But now they are organised in a way that should make it easier to find them.
Why
Ever since Grackle started supporting more than one database, there were three almost identical copies of .sql files in the repository. With more tests and especially even more backends on the horizon, these have become unwieldy and redundant.
Layout
A dataset is now one directory under
testdata:The remaining .sql files
For now, the actual CREATE TABLE parts are left as is. They are specific to the dialect. The data, however, not so much.
The directory structure
Grouping by dataset rather than by dialect puts both halves of one fixture in one place.
At container-up time the schema and the rows are written together into
target/testdata/<dialect>/<dataset>.sql, which is what docker compose mounts into the container's init directory.The CSV format
It is inspired by postgres'
COPY ... FROM STDINblocks. Hence\Nfor NULL, for instance, and|as the separator. Almost all the .sql files have been converted into equivalent .csv. Two were not:mutation, which only creates a sequence, andqualified-names, which is Postgres only.Values the dialects spell differently
Most values are written as a string literal and handed to the database verbatim. The exceptions are arrays, dates, times, timestamps and booleans. For those, a column names its kind in the CSV header and each dialect renders it accordingly:
arraydrama,comedy'{"drama","comedy"}'string_array2('drama', 'comedy')'["drama", "comedy"]'date1974-10-07'1974-10-07'DATE '1974-10-07''1974-10-07'time19:35:00'19:35:00'INTERVAL '0 19:35:00' DAY TO SECOND (0)'19:35:00'timestamptz2020-05-22T19:35:00ZTIMESTAMP '2020-05-22 19:35:00 +00:00''2020-05-22 19:35:00 +00:00'booleantrue'TRUE''TRUE'1Oracle is a bit extra and builds an array by calling its collection type, so the constructor name is read out of the column's type in Oracle's own schema. Note: The CSV is completely dialect-agnostic.
Two data changes
Resolved in favour of what two of the three dialects already did:
'-', as in the other two, because Oracle reads the empty string as NULL and the column isNOT NULLcountrylanguage.isofficialis written1/0, which all three acceptWhat did not change
No test code was changed, and no data except for the two values above.
The statements are shaped differently, since they are generated now: Postgres gets
INSERTs where it hadCOPY ... FROM STDINblocks, and Oracle gets one multi-rowVALUESwhere some scripts had a statement per row. The values are the same, 500 rows to a statement.Also here
sbt "newDataset foo"writes the three schema skeletons so a new dataset starts in the right shapesbt checkTestDatarenders every dataset in memory and reports what does not line up: a CSV whose table no schema creates, a header naming an unknown kind, a ragged row, a dataset with no scripts. It needs no database, so CI runs itdocker composedirectly, and a bind mount whose source is missing gets created by the daemon as root, which sbt then cannot write intoChecking it
sbt genTestDatawrites the scripts without starting anything, sotarget/testdatacan be diffed against a previous run. Every commit here was checked that way.