Skip to content

Commit 1455d82

Browse files
rustyconoverclaude
andcommitted
engine: move to DuckDB 2.0.0 / Haybarn 2.0.0rc11
The DuckDB vgi extension runs on DuckDB 2.0, but vgi-python still pinned its engine (and the vgi.duckdb.standard.v1 filter oracle) to DuckDB 1.5.5 / Haybarn 1.5.5rc1. An environment with haybarn 2.0 installed refused every pushed-down filter. - Retarget the standard.v1 oracle to upstream DuckDB v2.0.0 (d54cbbe3df) with Haybarn v2.0.0-rc11 (9b1a0c5829) as reference distribution: spec section 6, adapter guide, STANDARD_V1_ENGINE_VERSIONS, the duckdb/haybarn extras and the dev pin. The full filter conformance corpus passes unchanged on both 2.0 builds and the runtime corpus regenerates byte-identical. - _expression_grammar: read DuckDB 2.0's json_serialize_sql shape (untyped constant `literal`, function `arguments`, cast `type_expr`), typing literals and cast targets through the engine as the extension's ToValue()/TryDefaultBind do. Named function arguments are rejected, as the extension does. The 1.5 shape is still read. - arrow_table()/arrow_reader() helpers: 2.0 types to_arrow_table() and to_arrow_reader() as optional. - Relations no longer have fetchone(); the null_on_division_by_zero probe silently swallowed that AttributeError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent cbee1f2 commit 1455d82

15 files changed

Lines changed: 234 additions & 123 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ updates:
2828
# security tab. The real fix is lifting the cap upstream in vgi-rpc.
2929
- dependency-name: "aiohttp"
3030
# The filter evaluator implements vgi.duckdb.standard.v1, pinned to
31-
# DuckDB 1.5.5 / Haybarn 1.5.5-rc1 (vgi/filter_v2.py
31+
# DuckDB 2.0.0 / Haybarn 2.0.0-rc11 (vgi/filter_v2.py
3232
# STANDARD_V1_ENGINE_VERSIONS); any other engine build refuses every
3333
# pushed-down filter. Bumping them is a deliberate profile decision, not
3434
# a routine update: locking duckdb 1.5.6 broke filter pushdown in the

‎conformance/filter-v2/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The corpus has two layers:
1818
manifest.
1919
- `runtime-manifest.json` indexes the executable Arrow vectors under `runtime/` and records a SHA-256 digest for every
2020
file.
21-
- `generate_runtime.py` deterministically regenerates the runtime corpus with DuckDB 1.5.5 reference semantics.
21+
- `generate_runtime.py` deterministically regenerates the runtime corpus with DuckDB 2.0.0 reference semantics.
2222
- `run_worker.py` sends the portable subset through the public VGI client to any compatible worker executable. For
2323
example:
2424

‎docs/protocol/vgi-duckdb-filter-adapter.md‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
**Status:** Proposed implementation guide
44
**Target protocol:** VGI 2.0.0
55
**DuckDB adapters:** 1.5.x and 2.0
6-
**Initial expression semantics:** `vgi.duckdb.standard.v1` (upstream DuckDB v1.5.5)
6+
**Initial expression semantics:** `vgi.duckdb.standard.v1` (upstream DuckDB v2.0.0)
77
**Normative wire specification:** [VGI Filter Encoding v2](vgi-filter-encoding-v2-spec.md)
88

99
## 1. Scope
@@ -18,7 +18,7 @@ Both DuckDB adapters:
1818

1919
- emit only `vgi.filters.v2`;
2020
- set each filter document's `semantics` to `vgi.duckdb.standard.v1` only after the worker advertises that profile and
21-
the adapter proves that the bound expression matches upstream DuckDB v1.5.5 behavior;
21+
the adapter proves that the bound expression matches upstream DuckDB v2.0.0 behavior;
2222
- use `vgi.none.v1` for a scan whose filters are all independent of DuckDB session context;
2323
- use `vgi.duckdb.session.v1` only after verifying that DuckDB's `icu` extension supplied the bound `TimeZone` and
2424
`Calendar` settings, capturing `default_collation`, `ieee_floating_point_ops`, and `integer_division`, and confirming
@@ -51,10 +51,11 @@ DuckDB 1.5 exposes concrete `TableFilter` subclasses and single-column table-fun
5151

5252
The DuckDB 1.5 API offers one root scan column, so this adapter emits only single-column expressions even though the VGI wire permits multiple references. This is an engine-adapter limitation, not a protocol restriction.
5353

54-
The v1 semantic oracle is upstream DuckDB v1.5.5 commit
55-
`d8cdaa33fda8df955cc76ef58a280f68f4cd43fa`. Haybarn v1.5.5-rc1 commit
56-
`105edd31b57fe7e6d32ee648efad562e45a9f908` is a reference distribution expected to pass the same corpus; upstream
57-
behavior wins if an unlisted Haybarn patch differs.
54+
The v1 semantic oracle is upstream DuckDB v2.0.0 commit
55+
`d54cbbe3df17e8e5ce68312f483b4155836112aa`. Haybarn v2.0.0-rc11 commit
56+
`9b1a0c5829c056edaecd8ee8e7249a70fb8f50c8` is a reference distribution expected to pass the same corpus; upstream
57+
behavior wins if an unlisted Haybarn patch differs. (It was DuckDB v1.5.5 while the extension ran on 1.5; see the
58+
specification, section 6.)
5859

5960
## 4. DuckDB 2.0 filter model
6061

@@ -78,9 +79,7 @@ It validates the resulting field name before serialization. Projected output pos
7879

7980
Multi-column predicates offered through DuckDB's partial table-function pushdown contract are advisory because DuckDB retains their exact residual. A single-column predicate may be required only when DuckDB's table-function contract removes the local filter and the complete VGI expression is supported exactly.
8081

81-
Until stable DuckDB 2.0 semantics are published, the 2.0 adapter emits `vgi.duckdb.standard.v1` only for expressions it
82-
can map exactly to the v1.5.5 oracle. After DuckDB 2.0 is released, its distinct behavior will be advertised as
83-
`vgi.duckdb.standard.v2`; it does not revise v1. Workers may advertise both, and the filter document selects one.
82+
The 2.0 adapter emits `vgi.duckdb.standard.v1` only for expressions it can map exactly to the v2.0.0 oracle.
8483

8584
## 5. Bound-expression mapping
8685

@@ -266,7 +265,7 @@ Generated VGI models should be used for request, response, and AST construction.
266265

267266
The DuckDB 1.5 integration suite covers:
268267

269-
- differential behavior against upstream DuckDB v1.5.5 and Haybarn v1.5.5-rc1 for the complete v1 conformance corpus;
268+
- differential behavior against upstream DuckDB v2.0.0 and Haybarn v2.0.0-rc11 for the complete v1 conformance corpus;
270269
- every concrete supported filter class;
271270
- required versus optional behavior;
272271
- nested struct fields;

‎docs/protocol/vgi-filter-encoding-v2-spec.md‎

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
**Encoding identifier:** `vgi.filters.v2`
66
**Filter version marker:** `2`
77
**Expression semantics:** `vgi.duckdb.standard.v1`
8-
**Normative engine oracle:** DuckDB `v1.5.5` (`d8cdaa33fda8df955cc76ef58a280f68f4cd43fa`)
8+
**Normative engine oracle:** DuckDB `v2.0.0` (`d54cbbe3df17e8e5ce68312f483b4155836112aa`)
99

1010
## 1. Purpose
1111

@@ -664,24 +664,28 @@ Artifact formats, capability rules, algorithm registration, DuckDB Bloom and pre
664664
## 6. Standard semantics and function set
665665

666666
`vgi.duckdb.standard.v1` defines the semantics of both core expression nodes and the deliberately small standard
667-
function set below. Its normative oracle is the observable SQL behavior of upstream DuckDB `v1.5.5`, tag commit
668-
`d8cdaa33fda8df955cc76ef58a280f68f4cd43fa`, after applying the evaluation-context settings required by section 11.3.
669-
It is not a reference to the moving `1.5.x` release family.
667+
function set below. Its normative oracle is the observable SQL behavior of upstream DuckDB `v2.0.0`, tag commit
668+
`d54cbbe3df17e8e5ce68312f483b4155836112aa`, after applying the evaluation-context settings required by section 11.3.
669+
It is not a reference to the moving `2.0.x` release family.
670670

671-
Haybarn `v1.5.5-rc1`, tag commit `105edd31b57fe7e6d32ee648efad562e45a9f908`, is a reference distribution built
672-
on that upstream release and is expected to conform to `vgi.duckdb.standard.v1`. If an unlisted Haybarn modification
673-
and upstream DuckDB v1.5.5 produce different observable expression behavior, upstream DuckDB v1.5.5 is the tie-breaking
671+
Haybarn `v2.0.0-rc11`, tag commit `9b1a0c5829c056edaecd8ee8e7249a70fb8f50c8`, is a reference distribution built
672+
on DuckDB 2.0 and is expected to conform to `vgi.duckdb.standard.v1`. If an unlisted Haybarn modification
673+
and upstream DuckDB v2.0.0 produce different observable expression behavior, upstream DuckDB v2.0.0 is the tie-breaking
674674
oracle unless this specification explicitly states otherwise.
675675

676+
The profile's oracle was originally upstream DuckDB v1.5.5 (Haybarn v1.5.5-rc1). It moved to DuckDB v2.0.0 when the
677+
DuckDB `vgi` extension moved to DuckDB 2.0, so that the producer and the reference evaluator run the same engine; the
678+
complete conformance corpus passes unchanged on both 2.0 builds.
679+
676680
The profile covers values, logical result types, NULL behavior, errors by category, overload selection, coercion, and
677681
the effects of encoded session settings. Exact diagnostic wording, private expression classes, optimizer choices, and
678682
physical execution algorithms are not semantic results. The normative sources have this precedence: explicit rules in
679-
this specification; observable upstream DuckDB v1.5.5 behavior for cases those rules do not fix; and conformance-corpus
683+
this specification; observable upstream DuckDB v2.0.0 behavior for cases those rules do not fix; and conformance-corpus
680684
vectors as executable examples. A corpus vector that conflicts with either higher-precedence source is a corpus defect
681685
and MUST NOT redefine the profile.
682686

683-
This behavior does not change merely because an installed DuckDB version changes. When stable DuckDB 2.0 semantics are
684-
adopted, they will be published as `vgi.duckdb.standard.v2`; they will not silently redefine v1. A producer or consumer
687+
This behavior does not change merely because an installed DuckDB version changes. A later change of oracle is made
688+
only by editing this section, never by accepting whatever engine a consumer happens to have installed. A producer or consumer
685689
may support both profiles, and the document-level `semantics` value selects one unambiguously.
686690

687691
### 6.1 `starts_with`
@@ -1074,7 +1078,7 @@ The deprecated DuckDB setting `null_on_division_by_zero` is not encoded. The pro
10741078
producer with that setting enabled MUST decline every division, modulo, or function expression whose behavior it can
10751079
affect, rather than silently translating it under the profile. An embedded-DuckDB consumer MUST verify that the setting
10761080
is `false` before binding affected expressions and MUST NOT inherit a connection-local `true` value. The setting does
1077-
not exist in the v1.5.5 oracle; absence there is the fixed-false reference behavior rather than an error.
1081+
not exist in the v2.0.0 oracle; absence there is the fixed-false reference behavior rather than an error.
10781082

10791083
The producer sends a context-dependent predicate only after matching the profile against
10801084
`filter_evaluation_contexts`. If the profile is unsupported, a required predicate is not delegated and an advisory
@@ -1341,8 +1345,8 @@ Required positive cases include:
13411345
fingerprint;
13421346
26. successful strict matching when producer, advertised capability, and filter batch carry the identical provider
13431347
fingerprint; and
1344-
27. core-node values, result types, NULLs, and error categories matching upstream DuckDB v1.5.5 under
1345-
`vgi.duckdb.standard.v1`, with Haybarn v1.5.5-rc1 passing the same corpus.
1348+
27. core-node values, result types, NULLs, and error categories matching upstream DuckDB v2.0.0 under
1349+
`vgi.duckdb.standard.v1`, with Haybarn v2.0.0-rc11 passing the same corpus.
13461350

13471351
Exact-evaluation parity cases include arithmetic overflow, integer and floating-point division by zero, and failing
13481352
casts. Each case verifies whether evaluation returns a value or raises an error, along with the error category required
@@ -1409,7 +1413,7 @@ VGI 2.0 performs a direct replacement:
14091413
13. Mark context-independent batches with `vgi.none.v1`; for negotiated DuckDB-session batches, carry the bound time
14101414
zone, calendar, default collation, IEEE floating-point policy, and integer-division policy plus an optional strict
14111415
provider fingerprint as immutable schema metadata.
1412-
14. Select `vgi.duckdb.standard.v1` in every initial filter document and pin it to upstream DuckDB v1.5.5 semantics.
1416+
14. Select `vgi.duckdb.standard.v1` in every initial filter document and pin it to upstream DuckDB v2.0.0 semantics.
14131417
15. Reject every VGI 1.x peer before bind or execution.
14141418

14151419
The Python SDK should implement the schema, generated model, validation, reference evaluator, and corpus first. Other language SDKs consume the generated schema and implement decoding/evaluation without designing independent wire shapes. DuckDB-specific work follows [VGI DuckDB Filter Adapter](vgi-duckdb-filter-adapter.md).
@@ -1420,9 +1424,8 @@ This proposal makes the following choices:
14201424

14211425
- VGI 2.0 has one filter encoding and no v1 compatibility mode.
14221426
- The wire is a unified expression AST inside the existing Arrow IPC container.
1423-
- `vgi.duckdb.standard.v1` pins core and standard-function behavior to upstream DuckDB v1.5.5; Haybarn
1424-
v1.5.5-rc1 is a conforming reference distribution.
1425-
- Stable DuckDB 2.0 behavior will be introduced as `vgi.duckdb.standard.v2`, without changing v1.
1427+
- `vgi.duckdb.standard.v1` pins core and standard-function behavior to upstream DuckDB v2.0.0; Haybarn
1428+
v2.0.0-rc11 is a conforming reference distribution.
14261429
- Embedded DuckDB is the recommended portable evaluator.
14271430
- DataFusion native pushdown is an optional deeper optimization with a residual correctness backstop.
14281431
- Polars is treated primarily as a client and retains its native residual.

‎pyproject.toml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ dependencies = [
5454
# lazily in vgi/_duckdb.py: haybarn is preferred, stock duckdb is the
5555
# fallback. Neither is a hard dependency — install one via these extras.
5656
# Both are pinned EXACTLY: expression-filter evaluation implements
57-
# vgi.duckdb.standard.v1, whose oracle is upstream DuckDB 1.5.5 (Haybarn
58-
# 1.5.5-rc1), and vgi/filter_v2.py refuses any other engine build
57+
# vgi.duckdb.standard.v1, whose oracle is upstream DuckDB 2.0.0 (Haybarn
58+
# 2.0.0-rc11), and vgi/filter_v2.py refuses any other engine build
5959
# (STANDARD_V1_ENGINE_VERSIONS). A looser range lets a resolver pick e.g.
60-
# duckdb 1.5.6, and every pushed-down filter then fails to bind. Change these
60+
# duckdb 2.0.1, and every pushed-down filter then fails to bind. Change these
6161
# only together with STANDARD_V1_ENGINE_VERSIONS (a test keeps them in step).
6262
# numpy: the engine's create_function needs it, and the evaluator registers the
6363
# duckdb.spatial/intersects_extent@1 UDF with it (only for predicates that call
6464
# that function). Filter evaluation never runs without one of these extras, so
6565
# numpy belongs here rather than in the core dependencies.
66-
haybarn = ["haybarn==1.5.5rc1", "numpy>=2.4.1"]
67-
duckdb = ["duckdb==1.5.5", "numpy>=2.4.1"]
66+
haybarn = ["haybarn==2.0.0rc11", "numpy>=2.4.1"]
67+
duckdb = ["duckdb==2.0.0", "numpy>=2.4.1"]
6868
http = ["vgi-rpc[http]"]
6969
# Publishing and resolving immutable external catalog results needs the RPC
7070
# download/compression dependencies on every transport, including subprocess.
@@ -101,7 +101,7 @@ test-fixtures-writable = [
101101
"vgi-python[transactor]",
102102
]
103103
dev = [
104-
"duckdb==1.5.5", # pinned with the `duckdb` extra above
104+
"duckdb==2.0.0", # pinned with the `duckdb` extra above
105105
"mypy",
106106
"pyarrow-stubs",
107107
# pydoclint is intentionally NOT a project dependency: it pulls

‎tests/catalog/expression_reference.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import duckdb
1616
import pyarrow as pa
1717

18+
from vgi.catalog._expression_grammar import _cast_type_id, _constant_type_id, _function_arguments, _has_named_argument
1819
from vgi.catalog.capabilities import ROW_SCALAR_EXPRESSION
1920
from vgi.catalog.evaluation_context import QueryEvaluationContext
2021
from vgi.catalog.sql import SqlExpression
@@ -69,9 +70,9 @@ def check(expression: dict[str, Any]) -> None:
6970
dependencies.add(names[0])
7071
return
7172
constant_types = _TYPES | ({"DECIMAL", "DOUBLE", "FLOAT"} if role == "using" else set())
72-
if kind == "CONSTANT" and expression.get("value", {}).get("type", {}).get("id") in constant_types:
73+
if kind == "CONSTANT" and _constant_type_id(expression)[0] in constant_types:
7374
return
74-
if kind == "CAST" and expression.get("cast_type", {}).get("id") in _TYPES and not expression.get("try_cast"):
75+
if kind == "CAST" and _cast_type_id(expression) in _TYPES and not expression.get("try_cast"):
7576
check(expression["child"])
7677
return
7778
if kind == "COMPARISON" and expression.get("type") in {
@@ -101,9 +102,10 @@ def check(expression: dict[str, Any]) -> None:
101102
or expression.get("distinct")
102103
or expression.get("filter")
103104
or expression.get("order_bys", {}).get("orders")
105+
or _has_named_argument(expression)
104106
):
105107
raise ValueError("unsupported scalar function modifiers")
106-
for child in expression["children"]:
108+
for child in _function_arguments(expression):
107109
check(child)
108110
return
109111
if kind == "OPERATOR" and expression.get("type") in {

‎tests/catalog/test_macro_contract.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def resolve(item: MacroOverload, parameter: MacroParameter) -> TypedValueBatch:
352352
assert copied[0].serialize_to_bytes() == stored[0]
353353
connection.execute("CREATE MACRO original_macro(x := 40 + 2) AS x + 1")
354354
connection.execute("CREATE MACRO copied_macro(x := 42) AS x + 1")
355-
assert connection.sql("SELECT original_macro(), copied_macro()").fetchone() == (43, 43)
355+
assert connection.execute("SELECT original_macro(), copied_macro()").fetchone() == (43, 43)
356356

357357

358358
def test_default_resolution_failure_does_not_publish_partial_replacement() -> None:
@@ -370,6 +370,6 @@ def reject(item: MacroOverload, parameter: MacroParameter) -> TypedValueBatch:
370370
def test_duckdb_15_owns_typed_overload_resolution_and_duplicate_signature_errors() -> None:
371371
with duckdb.connect() as connection:
372372
connection.execute("CREATE MACRO typed_macro(x INTEGER) AS x + 1, (x VARCHAR) AS x || '!' ")
373-
assert connection.sql("SELECT typed_macro(2::INTEGER), typed_macro('v'::VARCHAR)").fetchone() == (3, "v!")
373+
assert connection.execute("SELECT typed_macro(2::INTEGER), typed_macro('v'::VARCHAR)").fetchone() == (3, "v!")
374374
with pytest.raises(duckdb.Error, match="Ambiguity|same parameters"):
375375
connection.execute("CREATE MACRO ambiguous_macro(x INTEGER) AS x, (y INTEGER) AS y + 1")

‎tests/test_filter_v2.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -728,11 +728,12 @@ def test_engine_pins_match_standard_v1_oracle() -> None:
728728
@pytest.mark.parametrize(
729729
("engine", "version", "accepted"),
730730
[
731-
("duckdb", "1.5.5", True),
732-
("haybarn", "1.5.5rc1", True),
733-
("duckdb", "1.5.6", False),
734-
("duckdb", "1.5.4", False),
735-
("haybarn", "1.5.6rc1", False),
731+
("duckdb", "2.0.0", True),
732+
("haybarn", "2.0.0rc11", True),
733+
("duckdb", "2.0.1", False),
734+
("duckdb", "1.5.5", False),
735+
("haybarn", "1.5.5rc1", False),
736+
("haybarn", "2.0.0rc10", False),
736737
],
737738
)
738739
def test_standard_v1_evaluator_requires_oracle_engine(

0 commit comments

Comments
 (0)