Repository navigation
fix(metadata): normalize native metadata to public schema - #364
Conversation
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
There was a problem hiding this comment.
Verdict: 1 Low
Looks good — a clean, well-tested fix that casts native Thrift metadata columns to the public JDBC schema with proper DataLoss handling for count mismatches and lossy/out-of-range casts. One low observation: the per-column cast is purely positional and doesn't verify field-name agreement, so it depends entirely on the documented canonical-order invariant.
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
There was a problem hiding this comment.
Verdict: 1 Low
Looks good — the fix is correct and well-tested. Verified against the JDBC reference driver (MetadataResultSetBuilder.java:1686 increments native GetColumns ordinals by one on the thrift-copy path), so the zero-based→one-based +1 direction is right; the safe:false cast is strictly more permissive than the previous try_new type check, and overflow/column-count/out-of-range cases are all unit-tested. One Low note about the shared helper dispatching the ordinal fix by field name. No wiremock/e2e test exercises the is_native routing end-to-end, but the direct unit tests on normalize_native_metadata_batch cover the core logic adequately.
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
There was a problem hiding this comment.
Verdict: 1 Low
Looks good — solid change with thorough unit + wiremock coverage (width cast, Utf8/LargeUtf8/View cast, one-based ordinal, overflow, column-count and narrowing-cast rejection). One low observation: the ordinal increment is dispatched by the public schema's field name over a purely positional zip, which is safe today but couples to the canonical-order invariant and to the fact that only GetColumns currently carries ORDINAL_POSITION among native-routed schemas.
| })? | ||
| }; | ||
|
|
||
| if field.name() != "ORDINAL_POSITION" { |
There was a problem hiding this comment.
🔵 Low — normalize_native_metadata_batch zips columns to the public schema positionally and decides the zero→one-based increment purely from the public schema's field.name() == "ORDINAL_POSITION" — it never checks the native column's own name/order. Two consequences worth noting:
-
Correctness rests entirely on the documented "native metadata already has the canonical Thrift column order" invariant. Column count is validated, but a divergence in column order would silently cast one native column into a differently-meaning public column (and, at the ORDINAL_POSITION slot,
+1a value that isn't actually the ordinal). Consider asserting the native field name matches at each position, or at least at the ORDINAL_POSITION slot, so a contract drift fails loudly as DataLoss rather than corrupting values. -
Latent coupling:
GET_PROCEDURE_COLUMNS_SCHEMAalso declares anORDINAL_POSITIONfield. It's safe today becauselist_procedure_columnsroutes throughThriftReshapingReaderand never calls this normalizer — but if a native path is added for procedure columns later, this name-based increment would fire there too (JDBCgetProcedureColumnsordinals are not the same zero-based case), silently off-by-one-ing them. A brief comment scoping this increment to GetColumns, or gating on the operation type rather than the field name, would prevent that.
Neither is an active bug; filing as low for the maintainability/robustness angle.
Native Thrift metadata can differ from the public JDBC contract in both physical Arrow types and values.
Cast arrays to the public schema while preserving already-matching arrays. Reject unexpected column counts and cast failures as DataLoss. Normalize native
ORDINAL_POSITIONvalues from zero-based to one-based, matching JDBC and the non-nativeSHOW COLUMNSpath; preserve nulls and reject overflow.Tests:
cargo +stable fmt --all -- --checkcargo clippy --all-targets -- -D warningscargo test