Repository navigation
Commit 9996717
committed
feat(reader): comparator parity — intervals_as_string + empty-result schema + composite + TIMESTAMP tz + getTables/getColumns metadata + named params
Eight comparator-parity fixes in the kernel's result-reader,
metadata-reshape, and parameter-binding pipelines, surfaced by the
python-comparator audit.
### 1. `intervals_as_string` post-processor option
pyarrow's Python bindings can't decode Arrow's `month_interval`
(id 21) at all. Every kernel-backend `SELECT *` over a table with
`INTERVAL YEAR TO MONTH` columns threw `ArrowNotImplementedError`.
32 / 88 comparator diffs.
- `ResultConfig::intervals_as_string` (default false) +
`PostProcessOptions::intervals_as_string`. When true, the
post-processor stringifies Interval / Duration columns to `Utf8`.
- Disjoint with the JSON-rewrite path; fused into one per-batch
walk. Renames `build_json_batch` → `build_rewritten_batch`.
### 2. PyO3 binding for both result-config knobs
Exposes `complex_types_as_json` and `intervals_as_string` as kwargs
on `Session(...)`. Merged into one `ResultConfig` so the toggles
don't clobber each other.
### 3. Empty-result schema fix: shared type-mapper + composite parsing
`extract_schema_from_manifest` was calling a local
`map_databricks_type` that handled ~10 type names. DECIMAL,
INTERVAL, VOID, ARRAY, MAP, STRUCT all fell through to `Utf8`.
- Delete the duplicate. Route through the shared
`metadata::type_mapping::databricks_type_to_arrow`. Pass
`col.type_text` instead of `col.type_name` so precision/scale
come through.
- Parse composite type text via recursive descent. Nested shapes
parse correctly; bad input falls back to `Utf8`.
### 4. TIMESTAMP is tz-aware (was reported as tz-less)
Plain TIMESTAMP is logically TIMESTAMP_LTZ; the non-empty wire
schema emits `Timestamp(Microsecond, Some("Etc/UTC"))`. Split the
TIMESTAMP / TIMESTAMP_NTZ match arms.
### 5. `getTables`: `types=[]` returns zero rows (was: returned all)
In `reshape_tables`, the `table_types` filter was treating
`Some(&[])` identically to `None` ("no filter"). Thrift backend
returns zero rows on an explicit empty array — the literal reading
of "filter accepting nothing". Picks Thrift's reading for parity.
### 6. `getColumns`: REMARKS null → ""
`reshape_columns` (and `reshape_tables`) emitted Arrow nulls for
REMARKS when the server didn't supply a comment. New
`utf8_column_or_empty(batch, name)` helper substitutes "" for null
entries.
### 7. `getColumns`: IS_AUTO_INCREMENT defaults to "NO"
Refactored `bool_string_to_yn` into a thin wrapper over
`bool_string_to_yn_with_default(batch, name, default)`. Each
callsite picks its null-fallback. IS_NULLABLE keeps the ""
default (genuine unknown for computed columns / views).
### 8. Named-parameter binding (new)
`StatementSpec.named_params` was rejected at execute time with
"named parameter bindings are not supported in v0 — SEA wire
format carries positional bindings only".
That conclusion was sourced from the kernel's local Rust
`StatementParameter` struct, which only had `ordinal`. The
canonical SEA proto (`sql_exec_api_service.proto`) defines:
message StatementParameter {
optional int32 ordinal = 1 [(visibility) = PUBLIC_UNDOCUMENTED];
optional string name = 2 [(databricks.openapi.field).openapi_required = true];
optional string value = 3;
optional string type = 4;
repeated StatementParameterValueArg args = 5;
}
`name` is the documented public field; `ordinal` is marked
`PUBLIC_UNDOCUMENTED` "for future extension to positional
parameters". The kernel's local types were out of sync.
- `StatementParameter` gains `name: Option<String>`; `ordinal`
becomes `Option<i32>`. Both serialize with
`skip_serializing_if = "Option::is_none"` so the JSON shape on
the wire matches the proto: a positional param sends only
`ordinal`, a named one sends only `name`.
- `named_typed_value_to_sea_parameter(name, value)` helper mirrors
the existing positional helper.
- `Statement::execute` forwards `spec.named_params` via the new
helper instead of rejecting.
- PyO3 gains `Statement.bind_named_param(name, value_str, sql_type)`
mirroring `bind_param`.
Server side: live e2e against a real warehouse confirms named-only
binding works. Mixed positional + named in one statement is
rejected by the server with
`INVALID_PARAMETER_MARKER_VALUE.MISSING_NAME` — bindings must be
uniformly one or the other.
## Comparator outcome
| | Before any kernel work | After this PR + connector #803 |
|---|---|---|
| **match / diff (of 132 cases)** | 60 / 88 | **97 / 34 / 1 skipped** |
| Bucket A (ArrowNotImplementedError) | 32 | 0 ✅ |
| `decimal_column` precision/scale | 88 (connector) | 0 ✅ |
| `decimal_column` type slot (empty) | 7 | 0 ✅ |
| Complex-type slots (fetchall_arrow) | 12 | 0 ✅ |
| `timestamp_column` tz slot | 1 | 0 ✅ |
| `getTables(types=[])` rows | 8 | 0 ✅ |
| `getColumns` IS_AUTO_INCREMENT cells | 5150 | 0 ✅ |
| `getColumns` REMARKS cells | 5122 | 3796 (residual real diffs) |
| Bucket B1 (named params) | 1 | 0 ✅ |
| Fully-clean (config × suite) pairs | 12 / 30 | 18 / 30 |
Remaining diffs cluster into documented buckets — see
`~/docs/python-kernel/comparator-diff-tasklist.md`.
## Test plan
- [x] `cargo test --lib` — 421/421 pass (3 new tests on top of #64
baseline: named StatementParameter JSON shape, named
TypedValue helper, named Binary rejection)
- [x] `cargo test --test v0_execute_wiremock` — 11/11
(`execute_rejects_named_params_in_v0` flipped to
`execute_sends_named_params_in_wire_form`)
- [x] `cargo test --test v0_execute_e2e -- --ignored` — live
against pecotesting warehouse. New: `select_with_named_params`
passes, `mixed_positional_and_named_params_is_server_side_error`
documents the server-side constraint.
- [x] Full thrift-vs-kernel comparator (132 cases): 97 / 34 / 1
skipped — bucket B1 confirmed dropped from 1 → 0.
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>1 parent 04c8625 commit 9996717
15 files changed
Lines changed: 1225 additions & 160 deletions
File tree
- pyo3/src
- src
- metadata
- reader
- post_processor
- statement
- types
- tests
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| |||
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| 96 | + | |
| 97 | + | |
94 | 98 | | |
95 | 99 | | |
96 | 100 | | |
| |||
140 | 144 | | |
141 | 145 | | |
142 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
143 | 155 | | |
144 | 156 | | |
145 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
95 | 94 | | |
96 | 95 | | |
97 | 96 | | |
| |||
126 | 125 | | |
127 | 126 | | |
128 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
129 | 154 | | |
130 | 155 | | |
131 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
393 | 409 | | |
394 | 410 | | |
395 | 411 | | |
| |||
399 | 415 | | |
400 | 416 | | |
401 | 417 | | |
| 418 | + | |
402 | 419 | | |
403 | 420 | | |
404 | 421 | | |
| |||
0 commit comments