Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
54 changes: 29 additions & 25 deletions vortex-sqllogictest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ sequentially for one engine. Each test is named `slt::<engine>::<relative-path>`

## Running tests

Some tests use TPC-H data at scale factor 0.1 and one shard of the partitioned ClickBench
dataset (about one million rows of `hits`). Generate both first, then run the suite with
`cargo nextest`:
Some tests use TPC-H and TPC-DS data at scale factor 0.1 and one shard of the partitioned
ClickBench dataset (about one million rows of `hits`). Generate them first, then run the suite
with `cargo nextest`:

```shell
./vortex-sqllogictest/slt/generate_data.sh
Expand All @@ -22,35 +22,39 @@ cargo test -p vortex-sqllogictest --test sqllogictests
```

`generate_data.sh` accepts dataset names to generate only some of the fixtures, for example
`./vortex-sqllogictest/slt/generate_data.sh tpch` or `... clickbench`. Run it with `--help` to list
the datasets. It runs each dataset's own script, `slt/tpch/generate_data.sh` or
`slt/clickbench/generate_data.sh`, which can also be run directly.

The generated Vortex and Parquet data lives under `slt/tpch/data/` and `slt/clickbench/data/`
(git-ignored). Both formats are required; regenerate older fixtures if they only contain Vortex
files. If either format is missing, that suite's tests are reported as **ignored**, so the rest of
the suite still runs. These `.slt` files load their tables through paths relative to the crate
root, so run the tests via `cargo nextest`/`cargo test`, which set the working directory
accordingly.

TPC-H scripts live under `slt/tpch/datafusion/` and `slt/tpch/duckdb/`, ClickBench scripts under
`./vortex-sqllogictest/slt/generate_data.sh tpch`, `... tpcds` or `... clickbench`. Run it with
`--help` to list the datasets. It runs each dataset's own script, `slt/tpch/generate_data.sh`,
`slt/tpcds/generate_data.sh` or `slt/clickbench/generate_data.sh`, which can also be run directly.
TPC-DS is generated by DuckDB's `tpcds` extension through `uvx`.

The generated Vortex and Parquet data lives under `slt/tpch/data/`, `slt/tpcds/data/` and
`slt/clickbench/data/` (git-ignored). Both formats are required; regenerate older fixtures if they
only contain Vortex files. If either format is missing, that suite's tests are reported as
**ignored**, so the rest of the suite still runs. These `.slt` files load their tables through
paths relative to the crate root, so run the tests via `cargo nextest`/`cargo test`, which set the
working directory accordingly.

TPC-H scripts live under `slt/tpch/datafusion/` and `slt/tpch/duckdb/`, TPC-DS scripts under
`slt/tpcds/datafusion/` and `slt/tpcds/duckdb/`, ClickBench scripts under
`slt/clickbench/datafusion/` and `slt/clickbench/duckdb/`. Each engine has its own
`create.slt.no`, `results/q*.slt.no` (`q1` to `q22` for TPC-H, `q0` to `q42` for ClickBench,
matching the upstream numbering), and `drop.slt.no`. Its `tpch.slt`/`clickbench.slt` runs these
against Vortex and asserts EXPLAIN output from the matching `plans/q*.slt.no`. Its `parquet.slt`
runs the same queries against the original Parquet fixtures and checks the same expected results.
`create.slt.no`, `results/q*.slt.no` (`q1` to `q22` for TPC-H, `q1` to `q99` for TPC-DS, `q0` to
`q42` for ClickBench, matching the upstream numbering), and `drop.slt.no`. Its
`tpch.slt`/`tpcds.slt`/`clickbench.slt` runs these against Vortex and asserts EXPLAIN output from
the matching `plans/q*.slt.no`. Its `parquet.slt` runs the same queries against the original
Parquet fixtures and checks the same expected results.
DataFusion uses external tables; DuckDB uses views over files. The `FILE_FORMAT` substitution
variable selects the format in each engine's table setup.

ClickBench plans explain the upstream queries unchanged. Where an upstream query leaves the order
of tied rows unspecified, its result record adds tie-breaking `ORDER BY` columns so both formats
and repeated runs produce the same rows. The ClickBench generator also runs
`slt/clickbench/duckdb/parity.slt` right after converting the shard; it reads both files through
DuckDB and fails if the Parquet and Vortex data differ. After completing ClickBench DataFusion
plans, replace the byte ranges in `file_groups` with `<slt:ignore>`, as the TPC-H plans do:
and repeated runs produce the same rows. The ClickBench and TPC-DS generators also run
`slt/clickbench/duckdb/parity.slt` and `slt/tpcds/duckdb/parity.slt` right after converting their
fixtures; they read both formats through DuckDB and fail if the Parquet and Vortex data differ.
After completing ClickBench or TPC-DS DataFusion plans, replace the byte ranges in `file_groups`
with `<slt:ignore>`, as the TPC-H plans do:

```shell
sed -i -E 's/hits\.vortex:[0-9]+\.\.[0-9]+/hits.vortex:<slt:ignore>/g' vortex-sqllogictest/slt/clickbench/datafusion/plans/*.slt.no
sed -i -E 's/\.vortex:[0-9]+\.\.[0-9]+/.vortex:<slt:ignore>/g' vortex-sqllogictest/slt/{clickbench,tpcds}/datafusion/plans/*.slt.no
```

Because the harness is `libtest-mimic`-based, the standard test flags work, including
Expand Down Expand Up @@ -123,7 +127,7 @@ engine currently produces, instead of comparing against it. This is useful after
change to query results or plan formatting.

```shell
# Complete every file (generate TPC-H and ClickBench data first if you want their result files updated):
# Complete every file (generate the TPC-H, TPC-DS and ClickBench data first if you want their result files updated):
cargo test -p vortex-sqllogictest --test sqllogictests -- --complete
# Complete only the files whose name matches a substring:
cargo test -p vortex-sqllogictest --test sqllogictests -- --complete strings
Expand Down
7 changes: 4 additions & 3 deletions vortex-sqllogictest/bin/sqllogictests-runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ fn engines_for(path: &Path) -> (bool, bool) {
/// Vortex and Parquet versions both have to exist for the suite to run.
const GENERATED_DATASETS: &[(&str, &str)] = &[
("tpch", "tpch/data/lineitem"),
("tpcds", "tpcds/data/store_sales"),
("clickbench", "clickbench/data/hits"),
];

Expand Down Expand Up @@ -242,9 +243,9 @@ fn main() -> anyhow::Result<ExitCode> {
let mut trials = Vec::new();
for path in files {
let (run_datafusion, run_duckdb) = engines_for(&path);
// TPC-H and ClickBench trials are ignored (rather than removed) when the
// generated data is absent, so `--list` and the run summary still
// account for them.
// Generated-data trials (TPC-H, TPC-DS, ClickBench) are ignored (rather
// than removed) when the data is absent, so `--list` and the run summary
// still account for them.
let ignored = missing_generated_data(&path);
let name = path
.strip_prefix(SLT_ROOT.as_path())
Expand Down
5 changes: 3 additions & 2 deletions vortex-sqllogictest/slt/generate_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
#
# Datasets:
# tpch TPC-H at scale factor 0.1.
# tpcds TPC-DS at scale factor 0.1 from DuckDB's tpcds extension.
# clickbench One shard (~1M rows) of the partitioned ClickBench `hits` table.
#
# With no arguments every dataset is generated.

set -e -o pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ALL_DATASETS=(tpch clickbench)
ALL_DATASETS=(tpch tpcds clickbench)

usage() {
echo "Usage: $(basename "${BASH_SOURCE[0]}") [DATASET...]"
Expand All @@ -32,7 +33,7 @@ for arg in "$@"; do
usage
exit 0
;;
tpch|clickbench)
tpch|tpcds|clickbench)
datasets+=("${arg}")
;;
*)
Expand Down
1 change: 1 addition & 0 deletions vortex-sqllogictest/slt/tpcds/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/data
127 changes: 127 additions & 0 deletions vortex-sqllogictest/slt/tpcds/datafusion/create.slt.no
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright the Vortex contributors

# Keep fixture paths under WORK_DIR so EXPLAIN output can normalize them.
# Plans ignore byte ranges because they depend on the generated fixture sizes.
system ok
cp slt/tpcds/data/*.$FILE_FORMAT "$WORK_DIR/"

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS call_center
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/call_center.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS catalog_page
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/catalog_page.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS catalog_returns
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/catalog_returns.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS catalog_sales
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/catalog_sales.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS customer
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/customer.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS customer_address
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/customer_address.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS customer_demographics
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/customer_demographics.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS date_dim
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/date_dim.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS household_demographics
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/household_demographics.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS income_band
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/income_band.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS inventory
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/inventory.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS item
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/item.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS promotion
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/promotion.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS reason
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/reason.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS ship_mode
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/ship_mode.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS store
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/store.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS store_returns
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/store_returns.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS store_sales
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/store_sales.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS time_dim
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/time_dim.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS warehouse
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/warehouse.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS web_page
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/web_page.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS web_returns
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/web_returns.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS web_sales
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/web_sales.${FILE_FORMAT}';

statement ok
CREATE EXTERNAL TABLE IF NOT EXISTS web_site
STORED AS ${FILE_FORMAT}
LOCATION '${WORK_DIR}/web_site.${FILE_FORMAT}';
74 changes: 74 additions & 0 deletions vortex-sqllogictest/slt/tpcds/datafusion/drop.slt.no
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright the Vortex contributors

statement ok
DROP TABLE web_site;

statement ok
DROP TABLE web_sales;

statement ok
DROP TABLE web_returns;

statement ok
DROP TABLE web_page;

statement ok
DROP TABLE warehouse;

statement ok
DROP TABLE time_dim;

statement ok
DROP TABLE store_sales;

statement ok
DROP TABLE store_returns;

statement ok
DROP TABLE store;

statement ok
DROP TABLE ship_mode;

statement ok
DROP TABLE reason;

statement ok
DROP TABLE promotion;

statement ok
DROP TABLE item;

statement ok
DROP TABLE inventory;

statement ok
DROP TABLE income_band;

statement ok
DROP TABLE household_demographics;

statement ok
DROP TABLE date_dim;

statement ok
DROP TABLE customer_demographics;

statement ok
DROP TABLE customer_address;

statement ok
DROP TABLE customer;

statement ok
DROP TABLE catalog_sales;

statement ok
DROP TABLE catalog_returns;

statement ok
DROP TABLE catalog_page;

statement ok
DROP TABLE call_center;
11 changes: 11 additions & 0 deletions vortex-sqllogictest/slt/tpcds/datafusion/parquet.slt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright the Vortex contributors

include ../../setup.slt.no

let FILE_FORMAT
SELECT 'parquet';

include ./create.slt.no
include ./results/*.slt.no
include ./drop.slt.no
Loading
Loading