Commit 94d63bd
authored
[SEA-NodeJS] SEA query parameters, metadata & getInfo (#412)
* [SEA-NodeJS] SEA query params, metadata & getInfo
Wire three SEA session-backend capabilities onto the merged-kernel napi
surface, all as thin adapters over the kernel (which owns the heavy lifting):
- Bound parameters: forward `ordinalParameters`/`namedParameters` to the
kernel's `ExecuteOptions.positionalParams`/`namedParams`, reusing the
existing `DBSQLParameter.toSparkParameter` codec (DECIMAL→DECIMAL(p,s),
INTERVAL→INTERVAL, NULL→VOID). Positional and named are mutually exclusive.
- Metadata: `getCatalogs`/`getSchemas`/`getTables`/`getColumns`/`getFunctions`/
`getTableTypes`/`getTypeInfo`/`getPrimaryKeys`/`getCrossReference` forward to
the kernel `Connection.list*`/`get*` calls and wrap the returned Statement.
The kernel owns SQL synthesis, column projection, and the client-side
`TABLE_TYPE` filter — the driver only maps request fields to arguments.
- getInfo: synthesized client-side (no SEA/kernel endpoint), mirroring the
three TGetInfoType values the Databricks Thrift server answers and rejecting
the rest, byte-identical to the Thrift path.
`SeaInputValidation` is slimmed to the one bind-time gate the driver needs
(`assertBindableValue`); marker counting is the kernel's job. Re-exports the
kernel's `ExecuteOptions`/`TypedValueInput` types from `SeaNativeLoader` rather
than re-declaring them, so the driver param shapes can't drift from the kernel.
Regenerates the committed napi `.d.ts` snapshot against the merged kernel.
Validated against a live warehouse: positional + named params, mutual-exclusion
rejection, all metadata calls (incl. kernel-side tableTypes filter), and getInfo.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
* [SEA-NodeJS] Address code-review findings on params/metadata/getInfo
Code-review-squad #412 review (79/100). Validated each finding against the
kernel source + a live warehouse before fixing:
- F1 (HIGH): getPrimaryKeys turned an omitted catalog into `?? ''`, which the
kernel's `Identifier::new` rejects with an opaque "identifier must not be
empty" — a regression vs Thrift (which forwards undefined). The napi
`getPrimaryKeys(catalog: string, …)` requires a non-empty catalog, so reject
up front with a clear, actionable message and document the divergence. Added
a test (omitted + empty-string catalog) asserting the kernel call is never
reached. (getCrossReference is unaffected — its parent args are nullable and
passed through without `?? ''`.)
- F3 (MED): mutual-exclusivity of ordinal/named params threw HiveDriverError
with a different message than the Thrift path, which throws
ParameterError('Driver does not support both ordinal and named parameters.')
(ParameterError extends Error, not HiveDriverError — so a caller catching it
worked on Thrift and silently failed on SEA). Now throws the identical
ParameterError + message. Test updated.
- F2 (MED): empirically re-verified against the live warehouse over Thrift —
the server returns the exact same three values we synthesize ("Spark SQL" /
"Spark SQL" / "3.1.1") and errors on every other TGetInfoType (probed
CLI_MAX_DRIVER_CONNECTIONS, CLI_DATA_SOURCE_NAME, …). So throwing on an
unsupported type matches Thrift's effective behaviour rather than narrowing
it; softened the "byte-for-byte" assertion into the validated fact in both
the SeaServerInfo and getInfo doc comments.
- F4 (LOW): getInfo's rejection now names the accepted enum identifiers/values
(CLI_SERVER_NAME (13), CLI_DBMS_NAME (17), CLI_DBMS_VER (18)) so an
agent/SDK consumer can self-correct.
- F5 (LOW): metadata + bound-param execute failures now emit a debug-level
breadcrumb (mapped error + session id) before throwing, via a shared
`logAndMapError` helper, matching the rest of the SEA backend's logging.
- F7 (LOW): dropped the vestigial `nativeStatement!` non-null assertion in
executeStatement (typed the local, mirroring runMetadata).
- F8 (test): added coverage for the getPrimaryKeys omitted-catalog path (F1),
the INTERVAL *→INTERVAL collapse, and the DECIMAL precision clamp-to-38.
F6 (kernel diagnostic getters unconsumed) is tracked as a follow-up — wiring
them in must land with the errorDetailsJson size-guard, out of scope here.
Validated live: getPrimaryKeys(with/without catalog), the ParameterError
parity, and the named-identifier getInfo error all behave as asserted.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
* [SEA-NodeJS] prettier-format SEA test files (CI code-style)
The CI "Check code style" step runs `prettier . --check` (whole repo), not
just eslint; these SEA test files were committed without prettier formatting
and failed it. Formatting-only; no behavioural change.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
* [SEA-NodeJS] Fix DECIMAL (p,s) derivation — reject overflow/non-numeric, drop leading-zero miscount
Code-review #412 (gopalldb P1). `decimalPrecisionScale` derived precision by
counting digit characters, which (a) counted insignificant leading zeros
("0.00001" → DECIMAL(6,5)) and (b) clamped precision to 38 while still sending
the full value — so a 40-digit value produced DECIMAL(38,0) alongside an
unrepresentable 40-digit value, which the kernel rejects or silently truncates.
The prior test blessed that clamp as correct (wrong contract).
Now:
- Precision = significant integer digits (insignificant leading zeros stripped,
matching Spark's decimal-literal rule) + fractional scale. "0.00001" →
DECIMAL(5,5); "007.50" → DECIMAL(3,2); "0" → DECIMAL(1,0).
- A value needing precision > 38 throws ParameterError at bind time instead of
clamp-and-send (P1.1).
- A non-numeric / exponential value ("1e+21", "abc", "") throws ParameterError
with a clear message rather than mis-deriving (p,s) and surfacing an opaque
kernel error (P1.2 / P2).
Validated live: 0.00001 binds as DECIMAL(5,5) and round-trips; a 40-digit value
is rejected client-side with ParameterError (no server round-trip). Unit tests
updated to assert the new reject contract + leading-zero handling.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
---------
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>1 parent de04e19 commit 94d63bd
11 files changed
Lines changed: 1202 additions & 78 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
| |||
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
49 | 62 | | |
50 | 63 | | |
51 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
0 commit comments