Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 68 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,32 @@ jobs:
- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y ninja-build

- name: Install uv for SQL host acceptance
id: uv
uses: ./.github/actions/setup-uv
with:
enable-cache: true
suffix: ${{ github.workflow }}-${{ github.job }}-${{ strategy.job-index || 0 }}

- name: Fetch unchanged upstream Yardstick tests
if: matrix.duckdb == 'v2.0.1'
uses: actions/checkout@v4
with:
repository: sidequery/yardstick
ref: 2b1318402b6be22b6417de5c83523f4b558c621f
path: sqlctx-duckdb/build/upstream-yardstick
sparse-checkout: test
persist-credentials: false

- name: Prepare the native SQLLogicTest subject and grammar fixture
if: matrix.duckdb == 'v2.0.1'
run: |
uv run --no-project sqlctx-duckdb/scripts/yardstick_upstream.py prepare \
--upstream sqlctx-duckdb/build/upstream-yardstick \
--duckdb-source sqlctx-duckdb/duckdb
echo "SQLCTX_YARDSTICK_FIXTURES=$PWD/sqlctx-duckdb/build/upstream-yardstick" >> "$GITHUB_ENV"
echo "EXTRA_EXTENSION_CONFIGS=$PWD/sqlctx-duckdb/test/yardstick_grammar/extension_config.cmake" >> "$GITHUB_ENV"

- name: Build DuckDB extension
working-directory: sqlctx-duckdb
run: make
Expand All @@ -867,13 +893,6 @@ jobs:
working-directory: sqlctx-duckdb
run: make test

- name: Install uv for SQL host acceptance
id: uv
uses: ./.github/actions/setup-uv
with:
enable-cache: true
suffix: ${{ github.workflow }}-${{ github.job }}-${{ strategy.job-index || 0 }}

- name: Fetch pinned community Yardstick for parser coexistence
if: matrix.duckdb == 'v1.5.6'
run: |
Expand All @@ -895,7 +914,20 @@ jobs:
SQLCTX_DUCKDB_EXTENSION: sqlctx-duckdb/build/release/extension/sqlctx/sqlctx.duckdb_extension
run: |
uv run --no-project --python 3.12 --with pytest --with pyyaml --with "duckdb==${DUCKDB_VERSION#v}" \
pytest -q -o addopts= sqlctx-duckdb/test --ignore=sqlctx-duckdb/test/test_duckflight_host.py
pytest -q -o addopts= sqlctx-duckdb/test \
--ignore=sqlctx-duckdb/test/test_duckflight_host.py \
--ignore=sqlctx-duckdb/test/test_iceberg_reopen_host.py

- name: Reopen a measure view from Iceberg in a second DuckDB process
if: matrix.duckdb == 'v2.0.1'
env:
SQLCTX_DUCKDB_BINARY: sqlctx-duckdb/build/release/duckdb
SQLCTX_DUCKDB_EXTENSION: sqlctx-duckdb/build/release/extension/sqlctx/sqlctx.duckdb_extension
run: |
"$SQLCTX_DUCKDB_BINARY" -no-init -bail :memory: -c 'install httpfs; install avro; install iceberg;'
sqlctx-duckdb/test/iceberg/run-with-catalog.sh \
uv run --no-project --python 3.12 --with pytest pytest -q -o addopts= \
sqlctx-duckdb/test/test_iceberg_reopen_host.py

- name: Exercise PostgreSQL BI discovery through released DuckFlight
if: matrix.duckdb == 'v2.0.1'
Expand All @@ -911,6 +943,34 @@ jobs:
echo "7e0c3a624f795b6dc756483ebc8b7e7af85c13cf33c301f86bcecc626444dbf7 $DUCKFLIGHT_EXTENSION" | sha256sum --check
uv run sqlctx-duckdb/test/test_duckflight_host.py

- name: Gate SQLCtx on every unchanged upstream Yardstick test
if: ${{ !cancelled() && matrix.duckdb == 'v2.0.1' }}
run: |
DUCKLAKE_ARCHIVE="$RUNNER_TEMP/ducklake.duckdb_extension.gz"
DUCKLAKE_EXTENSION="$RUNNER_TEMP/ducklake.duckdb_extension"
curl --fail --location --retry 3 \
https://extensions.duckdb.org/v2.0.1/linux_amd64/ducklake.duckdb_extension.gz \
--output "$DUCKLAKE_ARCHIVE"
echo "3c8d4b154527efd2ccf07e2f0294003cfcfd7087543ba667faafd9ae41c3f704 $DUCKLAKE_ARCHIVE" | sha256sum --check
gzip --decompress --stdout "$DUCKLAKE_ARCHIVE" > "$DUCKLAKE_EXTENSION"
uv run --no-project sqlctx-duckdb/scripts/yardstick_upstream.py run \
--upstream sqlctx-duckdb/build/upstream-yardstick \
--runner sqlctx-duckdb/build/release/test/unittest \
--runner-repository sqlctx-duckdb/build/release/repository \
--binary sqlctx-duckdb/build/release/duckdb \
--extension sqlctx-duckdb/build/release/extension/sqlctx/sqlctx.duckdb_extension \
--grammar-extension sqlctx-duckdb/build/release/extension/yardstick_test_grammar/yardstick_test_grammar.duckdb_extension \
--ducklake-extension "$DUCKLAKE_EXTENSION" \
--output-dir "$RUNNER_TEMP/yardstick-upstream-results"

- name: Upload upstream conformance records and native diagnostics
if: ${{ !cancelled() && matrix.duckdb == 'v2.0.1' }}
uses: actions/upload-artifact@v4
with:
name: yardstick-upstream-native-${{ matrix.duckdb }}
path: ${{ runner.temp }}/yardstick-upstream-results
if-no-files-found: error

- name: Save completed build caches
if: ${{ !cancelled() }}
uses: ./.github/actions/save-build-caches
Expand Down
17 changes: 11 additions & 6 deletions sqlctx-duckdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ When Yardstick is also loaded, its parser handles its measure declarations.
For an existing SQLCtx measure view in that configuration, select the metric
directly (`SELECT region, aov FROM yard_sales`) so SQLCtx evaluates it.

SQLCtx implements measure declarations, context modifiers, windows, PIVOT and
persistent definitions in its compiler and DuckDB extension. The window, predicate,
The [conformance gate](test/README.md#unchanged-upstream-yardstick-gate)
exercises measure declarations, context modifiers, windows, PIVOT and
persistent definitions against pinned upstream tests. SQLCtx implements these
operations in its compiler and DuckDB extension. The window, predicate,
decoration and aggregate-state helpers include code adapted from
[Yardstick under its MIT license](https://github.com/sidequery/yardstick/blob/2b1318402b6be22b6417de5c83523f4b558c621f/README.md#license).

Expand Down Expand Up @@ -693,7 +695,8 @@ rows, including equal-valued metrics on distinct customers.
Use `CREATE OR REPLACE` to update definitions; there is no `ALTER MODEL` syntax.
- In the model query compiler, explicit `GROUP BY` must repeat the selected
semantic dimensions. Measure views also support context modifiers, correlated
subqueries and grouping sets.
subqueries and grouping sets. The [conformance suite](test/README.md#unchanged-upstream-yardstick-gate)
exercises these forms.
- Native execution tests cover derived, ratio, cumulative, time-comparison,
conversion, retention, and cohort metrics. Retention produces a table with
cohort date, elapsed periods, active users, cohort size, and retention percentage;
Expand All @@ -717,9 +720,11 @@ as a string. The compatibility spellings are `yardstick` and `yardstick_scoped`.
`sqlctx_warning(message)` reports a warning. Enable `warnings_as_errors` to raise
an error instead. `sqlctx_state`, `sqlctx_combine` and `sqlctx_finalize` work with
exported aggregate states on DuckDB 2.0.1. Their `yardstick_*` spellings also work.
To keep measure definitions in a
specific catalog table (including DuckLake), set `yardstick_definition_table` to a
fully qualified `catalog.schema.table` name before creating the views.
To share measure definitions across DuckDB processes, set `yardstick_definition_table`
to a fully qualified `catalog.schema.table` before creating the views. A reader loads
SQLCtx, attaches the same catalogs under the same names, sets the same definition
table, and queries the view. The DuckDB 2.0.1 integration tests cover DuckLake and
a writable Iceberg REST catalog.

`sqlctx_explain(sql)` returns a JSON report from the same Rust compiler and current
catalog snapshot used by `sqlctx_rewrite_sql`:
Expand Down
Loading
Loading