diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2470a4..dd3ff83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,25 +134,38 @@ jobs: # The differential conftest spawns ``clickhouse local`` as a subprocess # and expects a binary at the repo root (see tests/differential/conftest.py). # We extract that binary from the clickhouse-server Docker image rather - # than running the image as a network service so the version is pinned - # to the same patch as the chDB Docker image (and the same one this - # dialect's docs claim parity against). + # than running the image as a network service. The tag is derived from + # the installed chDB core's own SELECT version() output so dependency + # bumps do not leave the reference binary on an older ClickHouse line. steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.12" + - run: | + python -m pip install --upgrade pip + pip install -e ".[dev,test-differential]" + - name: Detect chDB ClickHouse version + run: | + python - <<'PY' >> "$GITHUB_ENV" + import chdb + + version = str(chdb.query("SELECT version()", "TabSeparated")).strip() + parts = version.split(".") + if len(parts) < 3: + raise SystemExit(f"unexpected chDB ClickHouse version: {version!r}") + + print(f"CHDB_CLICKHOUSE_VERSION={version}") + print(f"CLICKHOUSE_TAG_PATCH={'.'.join(parts[:3])}") + print(f"CLICKHOUSE_TAG_MINOR={'.'.join(parts[:2])}") + PY - name: Extract clickhouse binary from server image run: | - # The tag must track chdb-core's ClickHouse baseline (26.5.1 as - # of chdb-core 26.5.0) — the differential test's own version - # check ([:3] of version()) fails loudly on drift, so a chdb - # baseline bump shows up here as a red version-skew test, not a - # silent pass. Try tags from most-specific to least-specific: - # patch tags (``X.Y.Z.W``) may rotate out, so fall back to the - # rolling ``X.Y.Z`` / ``X.Y`` tags. + # Try tags from most-specific to least-specific. Patch tags can + # rotate out, so fall back to the rolling X.Y tag for the same + # ClickHouse minor line. set -e - for tag in "26.5.1.882" "26.5.1" "26.5"; do + for tag in "$CLICKHOUSE_TAG_PATCH" "$CLICKHOUSE_TAG_MINOR"; do if docker pull "clickhouse/clickhouse-server:$tag" 2>/dev/null; then echo "Using clickhouse/clickhouse-server:$tag" docker create --name ch-extract "clickhouse/clickhouse-server:$tag" @@ -163,9 +176,6 @@ jobs: exit 0 fi done - echo "ERROR: no usable clickhouse-server tag found on Docker Hub" + echo "ERROR: no usable clickhouse-server tag found on Docker Hub for chDB $CHDB_CLICKHOUSE_VERSION" exit 1 - - run: | - python -m pip install --upgrade pip - pip install -e ".[dev,test-differential]" - run: pytest -ra -m differential tests/differential diff --git a/tests/differential/conftest.py b/tests/differential/conftest.py index 068edd3..6b2b61d 100644 --- a/tests/differential/conftest.py +++ b/tests/differential/conftest.py @@ -37,7 +37,7 @@ def _have_clickhouse_binary() -> bool: @pytest.fixture(scope="session") def clickhouse_local() -> ClickHouseLocal: - """Subprocess-backed reference ClickHouse 26.5.1 (stable). + """Subprocess-backed reference ClickHouse binary. Returns a callable wrapper that runs ``clickhouse local --query`` with a session-persistent in-memory database. Skipped automatically diff --git a/tests/differential/test_query_equivalence.py b/tests/differential/test_query_equivalence.py index c965a3f..dd8db18 100644 --- a/tests/differential/test_query_equivalence.py +++ b/tests/differential/test_query_equivalence.py @@ -1,9 +1,9 @@ -"""L5 — Differential testing: chDB vs ClickHouse 26.5.1 (stable) reference. +"""L5 — Differential testing: chDB vs the matching ClickHouse reference. For each query in :data:`QUERY_CORPUS`, we run it twice: 1. Through our SQLAlchemy dialect against the chDB engine -2. Directly through ``clickhouse local`` (the same v26.5.1.x build, +2. Directly through ``clickhouse local`` (the same major.minor.patch line, non-embedded) …then compare the row-string output. Mismatches are classified into @@ -284,7 +284,7 @@ def test_chdb_matches_reference( def test_version_strings_are_compatible(clickhouse_local, chdb_seeded_engine): - """Sanity check: chDB and the reference binary track the same 26.5.1 patch line. + """Sanity check: chDB and the reference binary track the same patch line. A real version mismatch (e.g. reference downloaded as 26.4.x by accident, or chDB diverging onto a later patch series) would invalidate every