|
| 1 | +// Copyright (c) 2026 Databricks, Inc. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +import { TGetInfoType, TGetInfoValue } from '../../thrift/TCLIService_types'; |
| 16 | + |
| 17 | +/** |
| 18 | + * `getInfo` (JDBC `DatabaseMetaData` / ODBC `SQLGetInfo`) is a Thrift-protocol |
| 19 | + * concept: the Thrift backend forwards `TGetInfoReq` to the server's `getInfo` |
| 20 | + * RPC. The SEA REST protocol and the Rust kernel have **no** equivalent |
| 21 | + * endpoint, so — exactly as JDBC does for `DatabaseMetaData` — we synthesize |
| 22 | + * the values client-side. |
| 23 | + * |
| 24 | + * The Databricks Thrift server itself answers only three `TGetInfoType`s and |
| 25 | + * rejects every other value; we mirror that surface byte-for-byte so the SEA |
| 26 | + * path is a drop-in equivalent: |
| 27 | + * |
| 28 | + * | TGetInfoType | Thrift server | SEA (here) | |
| 29 | + * |---------------------|---------------|-------------------| |
| 30 | + * | CLI_SERVER_NAME (13)| "Spark SQL" | "Spark SQL" | |
| 31 | + * | CLI_DBMS_NAME (17)| "Spark SQL" | "Spark SQL" | |
| 32 | + * | CLI_DBMS_VER (18)| "3.1.1" | "3.1.1" | |
| 33 | + * | (any other) | error | undefined → error | |
| 34 | + */ |
| 35 | + |
| 36 | +/** Canonical DBMS product name — identical to the Thrift server's value. */ |
| 37 | +export const SEA_DBMS_NAME = 'Spark SQL'; |
| 38 | + |
| 39 | +/** Server-name answer — identical to the Thrift server's value. */ |
| 40 | +export const SEA_SERVER_NAME = 'Spark SQL'; |
| 41 | + |
| 42 | +/** |
| 43 | + * DBMS version string. Mirrors the constant the Databricks Thrift server |
| 44 | + * reports for `CLI_DBMS_VER` (the HiveServer2-compat Spark SQL version, not |
| 45 | + * the DBR release). Kept in lock-step with Thrift for parity; if the server |
| 46 | + * ever changes it the comparator's GET_INFO suite flags the drift. |
| 47 | + */ |
| 48 | +export const SEA_DBMS_VERSION = '3.1.1'; |
| 49 | + |
| 50 | +/** |
| 51 | + * Synthesize the `TGetInfoValue` for a `getInfo` request on the SEA path. |
| 52 | + * Returns `undefined` for any `TGetInfoType` the (Thrift) server does not |
| 53 | + * answer — the caller surfaces that as an error, matching Thrift's |
| 54 | + * reject-unsupported-info-type behaviour. |
| 55 | + */ |
| 56 | +export function seaServerInfoValue(infoType: number): TGetInfoValue | undefined { |
| 57 | + switch (infoType) { |
| 58 | + case TGetInfoType.CLI_SERVER_NAME: |
| 59 | + return new TGetInfoValue({ stringValue: SEA_SERVER_NAME }); |
| 60 | + case TGetInfoType.CLI_DBMS_NAME: |
| 61 | + return new TGetInfoValue({ stringValue: SEA_DBMS_NAME }); |
| 62 | + case TGetInfoType.CLI_DBMS_VER: |
| 63 | + return new TGetInfoValue({ stringValue: SEA_DBMS_VERSION }); |
| 64 | + default: |
| 65 | + return undefined; |
| 66 | + } |
| 67 | +} |
0 commit comments