Repository navigation
fix(statement): bind GEOGRAPHY/GEOMETRY as STRING + bare WKT; drop VARIANT double-parse in test - #103
Merged
Merged
Conversation
…RIANT double-parse in test
Two issues in `rust-e2e.yml` against main (run 26737355105):
## 1. `bind_geography_and_geometry_round_trip` — kernel client-side bug
The kernel was sending geo binds with `param_type=GEOGRAPHY(SRID)`
(or bare `GEOGRAPHY` when no SRID was set) plus an EWKT value
`SRID=N;WKT`. SEA's `parameters` array does not accept either form:
- `param_type=GEOGRAPHY(4326)` → server returns
`INVALID_PARAMETER_MARKER_VALUE.INVALID_VALUE_FOR_DATA_TYPE`
("malformed value")
- `param_type=GEOGRAPHY` → server returns
`INVALID_PARAMETER_MARKER_VALUE.INVALID_DATA_TYPE`
("not a valid data type")
The wire format that DOES work — and which production JDBC users
follow — is to bind geo as `STRING` carrying bare WKT (no SRID
prefix), then parse it server-side with `ST_GeogFromText(?)` /
`ST_GeomFromText(?)` in the SQL. Those functions accept bare WKT
only; they reject the EWKT `SRID=N;WKT` prefix with
`WKT_PARSE_ERROR`. Callers needing an explicit SRID write
`ST_SetSRID(ST_GeogFromText(?), 4326)` in their SQL.
This commit:
- Maps `TypedValue::Geography { wkt, srid, .. }` and
`TypedValue::Geometry { wkt, srid, .. }` to
`param_type=STRING, value=wkt` on the wire (bare WKT,
SRID dropped from the value).
- Drops the now-dead `geo_param_type` / `geo_param_value`
helpers and the unused `geo_wire` import from
`src/statement/params.rs`.
- Consolidates the four geo unit tests into two looped tests
(per-variant) that assert the bare-WKT-as-STRING format
across both `srid=None` and `srid=Some(N)` inputs.
The `srid` field on the `TypedValue` variants stays on the
struct — informational only on the bind path today, kept so a
future SEA wire format that natively accepts EWKT or WKB can
pick it up without a breaking-variant change. The result-reader
path (which reads SRID from column metadata) is unchanged.
The `bind_geography_and_geometry_round_trip` E2E test's
assertion list works against the new format because
`ST_GeogFromText` defaults to SRID 4326 for bare WKT (which is
what the test asserts) and `ST_GeomFromText` defaults to SRID 0
(also what the test asserts). I also fixed one stale-comment
assertion in the same test: the Geometry WKT readback comes
back without extra spaces (`LINESTRING(0 0,1 1,2 2)` not
`LINESTRING(0 0, 1 1, 2 2)`).
Verified live against e2-dogfood: test passes end-to-end after
the change.
## 2. `bind_all_typed_values_round_trip` — test SQL bug
The test SQL was `PARSE_JSON(?) AS c_variant`. Since the kernel
binds `TypedValue::Variant` as `param_type=VARIANT`, SEA wraps
the marker server-side as `PARSE_JSON('...')`, so the outer
`PARSE_JSON(?)` is double-parsing. The server raises
`DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE: requires STRING, has
VARIANT` (the outer PARSE_JSON's STRING-typed input slot
receives the inner PARSE_JSON's VARIANT output).
Fix: drop the outer wrapper — `? AS c_variant` is correct; the
kernel's VARIANT typing on the parameter takes care of it.
Updated the surrounding comment to explain the contract for the
next reader.
The test now passes through the VARIANT bind; it still fails on
a pre-existing TIMESTAMP timezone assertion (line 432 — bound
`12:34:56` reads back as `19:34:56`, looks like Pacific-local
treatment of a no-tz TIMESTAMP). That's an independent bug
unrelated to VARIANT/GEO bind formatting; out of scope for this
PR.
Co-authored-by: Isaac
|
Kernel integration tests triggered for View status — the check entry carries the receiver-supplied link to the actual workflow run. |
vikrantpuppala
approved these changes
Jun 1, 2026
… in test PR #103 round-1's VARIANT fix was wrong. CI run 26739775725 on the PR showed `bind_all_typed_values_round_trip` panicked at line 455 with "VARIANT structural mismatch": left: String("{\"k\":1,\"arr\":[true,null,\"x\"]}") right: Object {"arr": [...], "k": Number(1)} The previous round (`? AS c_variant` + `param_type=VARIANT`) stops the server from rejecting the bind, but the server stores the value as a **String-typed VARIANT** (the JSON text gets JSON-encoded as a quoted string) instead of parsing it into the Object/Array-typed VARIANT the test expects. The correct fix mirrors the geo binding pattern: kernel desugars the typed value to **STRING on the wire + raw JSON text in the value**, and the caller's SQL uses `PARSE_JSON(?)` to parse the string into a proper VARIANT column server-side. Three failure modes I worked through to land on this: 1. `PARSE_JSON(?) AS c_variant` + `param_type=VARIANT` (original test code): server double-parses, raises `DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE: outer PARSE_JSON requires STRING but received VARIANT`. ❌ 2. `? AS c_variant` + `param_type=VARIANT` (PR #103 round-1): server stores the value as a String-typed VARIANT, readback is a JSON-encoded string, test's structural assertion fails. ❌ 3. `PARSE_JSON(?) AS c_variant` + `param_type=STRING` (this commit): server parses the string into an Object-typed VARIANT, structural readback matches. ✅ Live-verified against e2-dogfood: - bind_all_typed_values_round_trip: passes through VARIANT; now fails on a pre-existing TIMESTAMP timezone assertion at line 436 (7-hour shift on c_ts, same shape as the failure in `select_returns_all_types_correctly:298` — both expose a single underlying TZ-handling bug unrelated to this PR). - bind_geography_and_geometry_round_trip: passes (unchanged from round-1; my geo fix was correct). - All other v0_execute_e2e tests pass except the two affected by the pre-existing TIMESTAMP issue. Also updates: - The `typed_value_variant_emits_json_pass_through` unit test (renamed to `..._emits_json_text_as_string_type`) to assert the new STRING param_type. - The doc comment on the `TypedValue::Variant` arm in `typed_value_to_sea_payload` to explain the bind-as-STRING contract — same shape as the geo arm right below it. - The inline test comment on the VARIANT bind step in `bind_all_typed_values_round_trip` to document why the `PARSE_JSON(?)` wrapper is required. Co-authored-by: Isaac Signed-off-by: Gopal Lal <gopal.lal@databricks.com>
|
Integration test approval reset New commits were pushed to this PR. The A maintainer must re-review the changes and re-add the label to trigger tests again. Latest commit: 97b9630 |
3 tasks done
gopalldb
added a commit
that referenced
this pull request
Jun 1, 2026
…#104) ## Summary Makes three v0_metadata_e2e tests workspace-portable. They hard-coded `main.information_schema` assumptions that don't hold across real Databricks workspaces — surfaced by PR #103's geo+VARIANT fixes letting `v0_execute_e2e` pass for the first time, which then let `set -e` in `rust-e2e.yml` execute `v0_metadata_e2e` and expose the latent bug. ## Failure under the old tests `rust-e2e.yml` against PR #103 (run [26741812085](https://github.com/databricks/databricks-sql-kernel/actions/runs/26741812085)): ``` thread 'list_schemas_returns_jdbc_columns' panicked at tests/v0_metadata_e2e.rs:134:5: expected 'information_schema', got ["dbdemos_iot_turbine", "default", "tableau_migration_testing"] thread 'list_tables_returns_jdbc_columns' panicked at tests/v0_metadata_e2e.rs:175:5: information_schema should expose at least one view thread 'list_columns_returns_jdbc_columns' panicked at tests/v0_metadata_e2e.rs:220:5: tables view should have columns ``` The kernel returned exactly what the server reported — `SHOW SCHEMAS IN main` on this workspace genuinely has no `information_schema` schema. Verified the same on two distinct workspaces: | Workspace | `SHOW SCHEMAS IN main` | `SHOW SCHEMAS IN samples` | |---|---|---| | e2-dogfood (AWS) | `[dbdemos_iot_turbine, default, tableau_migration_testing]` (no `information_schema`) | (samples available) | | `adb-6436897454825492` (Azure) | same 3 schemas as above — **identical output** | `[accuweather, bakehouse, healthverity, information_schema, nyctaxi, sec, tpcds_sf1, tpcds_sf1000, tpch, wanderbricks]` ✅ | So `main` is workspace-configurable and the test's assumption is broken on real workspaces. The `samples` catalog is Databricks-managed (seeded with the standard `nyctaxi` / `tpch` demo datasets) and present on every UC-enabled workspace. ## Changes 1. **Target the `samples` catalog**, not `main`. The rest of this file (e.g. `find_known_table:229`) already used `samples` for the PK/FK tests — this commit brings the `list_*` tests in line. `hive_metastore` deliberately not used: it's pre-UC and has different metadata semantics. 2. **Soft-assert `information_schema`'s presence.** It's part of the UC contract for every catalog, but a brand-new catalog may not surface it immediately. Replaced the hard `assert!` with `eprintln!` so a regression is still visible in CI log without failing the test on a workspace-config detail. JDBC column-shape assertions (load-bearing — every BI tool depends on them) stay strict. 3. **Soft-assert non-zero row counts** for `list_tables` and `list_columns` against `information_schema`. If the view exists, we get rows; if it doesn't on this particular workspace, the kernel correctly returns empty — we don't want to fail on that. 4. **Drop the `default` schema assertion entirely.** `default` is a UC config detail (auto-created per-catalog only when configured); not load-bearing for kernel behaviour. ## Test plan Verified live against **two distinct workspaces** (PAT held in memory only, not committed): | Workspace | Result | |---|---| | `adb-6436897454825492` (Azure, warehouse `2f03dd43e35e2aa0`) | All 9 `v0_metadata_e2e` tests pass ✅ | | `e2-dogfood.staging.cloud.databricks.com` (AWS, warehouse `864004c1b3961382`) | All 3 fixed tests pass ✅ | Local verifications: - [x] `cargo check --all-targets` — clean - [x] `cargo clippy --all-targets -- -D warnings` — clean - [x] `cargo test --lib` — 519/519 unit tests pass ## Out of scope There's a separate pre-existing TIMESTAMP-timezone bug in `v0_execute_e2e` (`bind_all_typed_values_round_trip:436` and `select_returns_all_types_correctly:298` — both surface a `12:34:56` → `19:34:56` 7-hour PDT shift). That's a kernel/server tz-handling issue distinct from this PR's scope; tracked separately. ## Companion PR PR #103 (geo + VARIANT bind fixes) is what unblocked `v0_execute_e2e` enough for `set -e` to reach `v0_metadata_e2e` and expose these failures. This PR depends on no commits from #103 — it's an independent fix off `main` — but the two together make the `rust-e2e.yml` CI green for the first time. Signed-off-by: Gopal Lal <gopal.lal@databricks.com> Signed-off-by: Gopal Lal <gopal.lal@databricks.com>
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two test failures in
rust-e2e.ymlagainst main (run 26737355105). The geo failure is a real kernel client-side bug; the VARIANT failure is a stale-SQL bug in the test.Fix 1 —
bind_geography_and_geometry_round_trip(kernel bug)The kernel was sending geo bindings with
param_type=GEOGRAPHY(SRID)(or bareGEOGRAPHY) plus an EWKTvalue=SRID=N;WKT. SEA'sparametersarray does not accept either form — verified against e2-dogfood:param_type=GEOGRAPHY(4326)+ EWKT valueINVALID_PARAMETER_MARKER_VALUE.INVALID_VALUE_FOR_DATA_TYPE("malformed value")param_type=GEOGRAPHY(bare) + EWKT valueINVALID_PARAMETER_MARKER_VALUE.INVALID_DATA_TYPE("not a valid data type")param_type=STRING+ EWKT value (caller wraps withST_GeogFromText(?))WKT_PARSE_ERROR: Invalid or unsupported type 'SRID=...'param_type=STRING+ bare WKT (caller wraps withST_GeogFromText(?))This matches the wire format production JDBC users follow: bind the WKT as a
String, parse server-side withST_GeogFromText(?)/ST_GeomFromText(?). Callers needing an explicit SRID writeST_SetSRID(ST_GeogFromText(?), 4326)in their SQL.The kernel change:
TypedValue::{Geography, Geometry}to(STRING, bare WKT)on the wire.geo_param_type/geo_param_valuehelpers and the unusedgeo_wireimport insrc/statement/params.rs.srid=Noneandsrid=Some(N)inputs.The
sridfield onTypedValue::Geography/Geometrystays — informational only on the bind path, kept for a future SEA wire format that natively accepts EWKT/WKB. The result-reader path (which reads SRID from column metadata) is unchanged.Verified live:
bind_geography_and_geometry_round_trippasses end-to-end after this change.Why the existing test assertions still work after dropping SRID
The test asserts SRID=4326 for Geography and SRID=0 for Geometry. Those are exactly the defaults of
ST_GeogFromText(4326 = WGS 84) andST_GeomFromText(0) on bare WKT input. So the test's existing assertion list happens to match what the new format produces.Why I also fixed one comment-vs-assertion drift
The test asserted Geometry WKT readback as
"LINESTRING(0 0, 1 1, 2 2)"(with spaces) and the comment said the server "reformats with spaces after commas". Empirically the server preserves the bound WKT verbatim:"LINESTRING(0 0,1 1,2 2)". Fixed the assertion + comment to match observed behaviour.Fix 2 —
bind_all_typed_values_round_trip(test-source bug)Test SQL was:
Since the kernel binds
TypedValue::Variantasparam_type=VARIANT, SEA wraps the marker server-side asPARSE_JSON('...'). The outerPARSE_JSON(?)then double-parses, and the server raisesDATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE: requires STRING, has VARIANT.Fix: drop the wrapper —
? AS c_variantis correct; the kernel's VARIANT typing on the parameter takes care of producing a VARIANT column.Updated the surrounding comment to explain the contract for the next reader.
Known follow-up
The test now passes through the VARIANT bind but still fails on a pre-existing TIMESTAMP assertion at line 432 — bound
12:34:56(UTC) reads back as19:34:56(Pacific-local wall-clock). That's an independent kernel/server timezone-handling issue unrelated to VARIANT/GEO bind formatting; out of scope for this PR. The test will be strictly better after this lands (one fully-fixed test, one moved past the VARIANT bug to expose a clearer downstream signal).Test plan
cargo check --all-targets— cleancargo clippy --all-targets -- -D warnings— cleancargo test --lib params::— 42 unit tests pass (was 44; 2 geo tests consolidated into 2 looped tests covering same scope)bind_geography_and_geometry_round_tripagainst e2-dogfood — passes ✅bind_all_typed_values_round_tripagainst e2-dogfood — gets past VARIANT (was the previous fail point); now hits the pre-existing TIMESTAMP assertion at line 432 (acknowledged out-of-scope)This pull request and its description were written by Isaac.