Skip to content

Commit c020f91

Browse files
committed
Merge remote-tracking branch 'origin/main' into msrathore/nodejs-cross-repo-ci
2 parents 677337a + 4b9e16e commit c020f91

69 files changed

Lines changed: 11020 additions & 90 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
"rules": {
1010
"class-methods-use-this": "off",
1111
"no-underscore-dangle": "off",
12+
"@typescript-eslint/no-unused-vars": [
13+
"error",
14+
{ "argsIgnorePattern": "^_", "varsIgnorePattern": "^_", "ignoreRestSiblings": true }
15+
],
16+
"@typescript-eslint/no-use-before-define": ["error", { "functions": false }],
17+
"no-continue": "off",
1218
"consistent-return": "off",
1319
"no-param-reassign": "off",
1420
"no-bitwise": "off",

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ Dockerfile* text
3131
#
3232
.gitattributes export-ignore
3333
.gitignore export-ignore
34+
35+
# napi-rs auto-generates these files from the kernel's `napi-binding/napi/`
36+
# crate; regenerated by `npm run build:native`. Tell git/GitHub they're
37+
# machine-generated so they collapse in diffs and are excluded from
38+
# blame and language stats.
39+
native/sea/index.d.ts linguist-generated=true
40+
native/sea/index.js linguist-generated=true

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,12 @@ coverage_unit
1010
dist
1111
*.DS_Store
1212
lib/version.ts
13+
14+
# SEA native binding — copied/generated from kernel workspace by `npm run build:native`.
15+
# The committed contract is `native/sea/index.d.ts` (TypeScript declarations) and
16+
# `native/sea/index.js` (the napi-rs platform router — small, stable, and required in
17+
# the publish tarball so a missing build step can't ship a tarball that can't load).
18+
# The `.node` binaries are large per-platform artifacts and must NOT be committed;
19+
# in production they arrive via the `@databricks/sql-kernel-<triple>` optional deps.
20+
native/sea/index.node
21+
native/sea/index.*.node

.npmignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
!dist/**/*
44
!thrift/**/*
55

6+
# SEA napi-rs router shim + TypeScript declarations. The router (index.js)
7+
# selects the per-platform `.node` artifact from `@databricks/sql-kernel-*`
8+
# optionalDependencies (populated when the kernel CI publishes them);
9+
# the .d.ts is the consumer-facing type contract.
10+
!native/sea/index.js
11+
!native/sea/index.d.ts
12+
613
!LICENSE
714
!NOTICE
815
!package.json

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ coverage
1111
dist
1212
thrift
1313
package-lock.json
14+
15+
# Generated by napi-rs from the kernel's `napi-binding/napi/` crate;
16+
# regenerated by `npm run build:native`. Format follows napi-rs's
17+
# defaults (no semicolons), not this repo's prettier config.
18+
native/sea/index.d.ts
19+
native/sea/index.js

KERNEL_REV

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8bedaabf69f5bce5a957a8775f29dbb8dbdd2e71

lib/DBSQLClient.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
112112

113113
private authType?: string;
114114

115+
private useProxy?: boolean;
116+
115117
private telemetryClient?: TelemetryClient;
116118

117119
private telemetryEmitter?: TelemetryEventEmitter;
@@ -415,6 +417,7 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
415417
// Connection parameters
416418
httpPath: this.httpPath,
417419
enableMetricViewMetadata: this.config.enableMetricViewMetadata,
420+
useProxy: this.useProxy,
418421
};
419422
}
420423

@@ -594,6 +597,7 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
594597
this.host = options.host;
595598
this.httpPath = options.path;
596599
this.authType = this.mapAuthType(options);
600+
this.useProxy = Boolean(options.proxy);
597601

598602
// Store enableMetricViewMetadata configuration
599603
if (options.enableMetricViewMetadata !== undefined) {
@@ -628,7 +632,7 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
628632
// pattern (see databricks-sql-python/src/databricks/sql/session.py).
629633
const internalOptions = options as ConnectionOptions & InternalConnectionOptions;
630634
const backend = internalOptions.useSEA
631-
? new SeaBackend()
635+
? new SeaBackend({ context: this })
632636
: new ThriftBackend({
633637
context: this,
634638
onConnectionEvent: (event, payload) => this.forwardConnectionEvent(event, payload),

lib/DBSQLParameter.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ export enum DBSQLParameterType {
88
STRING = 'STRING',
99
DATE = 'DATE',
1010
TIMESTAMP = 'TIMESTAMP',
11+
// `TIMESTAMP_NTZ` binds a timezone-free (wall-clock) timestamp. It is a real
12+
// Spark type, bound natively on both the Thrift and kernel backends (requires
13+
// a server that supports TIMESTAMP_NTZ; Spark 3.4+ / recent DBR).
14+
TIMESTAMP_NTZ = 'TIMESTAMP_NTZ',
15+
// `TIMESTAMP_LTZ` is an alias for `TIMESTAMP`: Spark has no distinct
16+
// TIMESTAMP_LTZ type — `TIMESTAMP` already carries local/instant (LTZ)
17+
// semantics. `toSparkParameter` therefore binds it as `TIMESTAMP` on the wire
18+
// (valid on both backends); it exists only as a self-documenting alias.
19+
TIMESTAMP_LTZ = 'TIMESTAMP_LTZ',
1120
FLOAT = 'FLOAT',
1221
DECIMAL = 'DECIMAL',
1322
DOUBLE = 'DOUBLE',
@@ -50,10 +59,16 @@ export class DBSQLParameter {
5059
return new TSparkParameter({ name }); // for NULL neither `type` nor `value` should be set
5160
}
5261

62+
// Map timezone-explicit timestamp aliases to their Spark wire type. Spark
63+
// has no distinct TIMESTAMP_LTZ type (TIMESTAMP carries LTZ semantics), so
64+
// bind it as TIMESTAMP — valid on both the Thrift and kernel backends.
65+
// TIMESTAMP_NTZ is a real Spark type and is bound natively.
66+
const wireType = this.type === DBSQLParameterType.TIMESTAMP_LTZ ? DBSQLParameterType.TIMESTAMP : this.type;
67+
5368
if (typeof this.value === 'boolean') {
5469
return new TSparkParameter({
5570
name,
56-
type: this.type ?? DBSQLParameterType.BOOLEAN,
71+
type: wireType ?? DBSQLParameterType.BOOLEAN,
5772
value: new TSparkParameterValue({
5873
stringValue: this.value ? 'TRUE' : 'FALSE',
5974
}),
@@ -63,7 +78,7 @@ export class DBSQLParameter {
6378
if (typeof this.value === 'number') {
6479
return new TSparkParameter({
6580
name,
66-
type: this.type ?? (Number.isInteger(this.value) ? DBSQLParameterType.INTEGER : DBSQLParameterType.DOUBLE),
81+
type: wireType ?? (Number.isInteger(this.value) ? DBSQLParameterType.INTEGER : DBSQLParameterType.DOUBLE),
6782
value: new TSparkParameterValue({
6883
stringValue: Number(this.value).toString(),
6984
}),
@@ -73,7 +88,7 @@ export class DBSQLParameter {
7388
if (this.value instanceof Int64 || typeof this.value === 'bigint') {
7489
return new TSparkParameter({
7590
name,
76-
type: this.type ?? DBSQLParameterType.BIGINT,
91+
type: wireType ?? DBSQLParameterType.BIGINT,
7792
value: new TSparkParameterValue({
7893
stringValue: this.value.toString(),
7994
}),
@@ -83,7 +98,7 @@ export class DBSQLParameter {
8398
if (this.value instanceof Date) {
8499
return new TSparkParameter({
85100
name,
86-
type: this.type ?? DBSQLParameterType.TIMESTAMP,
101+
type: wireType ?? DBSQLParameterType.TIMESTAMP,
87102
value: new TSparkParameterValue({
88103
stringValue: this.value.toISOString(),
89104
}),
@@ -92,7 +107,7 @@ export class DBSQLParameter {
92107

93108
return new TSparkParameter({
94109
name,
95-
type: this.type ?? DBSQLParameterType.STRING,
110+
type: wireType ?? DBSQLParameterType.STRING,
96111
value: new TSparkParameterValue({
97112
stringValue: this.value,
98113
}),

lib/contracts/IDBSQLSession.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,18 @@ export type ExecuteStatementOptions = {
1212
*/
1313
queryTimeout?: number | bigint | Int64;
1414
/**
15-
* @deprecated This option is no longer supported and will be removed in future releases
15+
* Selects the execution lifecycle. The only observable effect is WHEN
16+
* `executeStatement` resolves; the result data, schema, and error classes are
17+
* identical regardless.
18+
*
19+
* - **Thrift backend:** no-op. The Thrift path always submits asynchronously
20+
* (`runAsync: true` on the wire) and polls during fetch; this option is not
21+
* read.
22+
* - **Kernel backend (`useSEA`):** selects the kernel execution path —
23+
* `false`/unset (default) runs the blocking direct-results path (faster,
24+
* cancellable mid-compute); `true` submits and polls (returns a pending
25+
* handle before completion). Default is sync, matching the python
26+
* connector's `cursor.execute()`.
1627
*/
1728
runAsync?: boolean;
1829
maxRows?: number | bigint | Int64 | null;
@@ -27,6 +38,18 @@ export type ExecuteStatementOptions = {
2738
* These tags apply only to this statement and do not persist across queries.
2839
*/
2940
queryTags?: Record<string, string | null | undefined>;
41+
/**
42+
* SEA-only: server-side row cap for this statement (kernel `row_limit`). The
43+
* Thrift backend has no execute-time server cap, so this is a no-op there;
44+
* use `maxRows` for the cross-backend client-side fetch limit.
45+
*/
46+
rowLimit?: number;
47+
/**
48+
* SEA-only: per-statement Spark conf overlay (kernel `statement_conf`).
49+
* Merged with the serialized `queryTags` (which land under the reserved
50+
* `query_tags` key). Ignored by the Thrift backend.
51+
*/
52+
statementConf?: Record<string, string>;
3053
};
3154

3255
export type TypeInfoRequest = {

lib/contracts/InternalConnectionOptions.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,27 @@ export interface InternalConnectionOptions {
1818
* @internal Not stable; M0 stub only.
1919
*/
2020
useSEA?: boolean;
21+
22+
/**
23+
* SEA-only: kernel connection-pool size (`ConnectionOptions.max_connections`).
24+
* Validated as a positive integer within the napi `u32` range.
25+
* @internal SEA path only.
26+
*/
27+
maxConnections?: number;
28+
29+
/**
30+
* SEA-only: verify the server's TLS certificate. Secure-by-default — omit
31+
* to keep full chain + hostname verification; set `false` only to opt into
32+
* the insecure accept-anything mode.
33+
* @internal SEA path only.
34+
*/
35+
checkServerCertificate?: boolean;
36+
37+
/**
38+
* SEA-only: PEM-encoded CA certificate (string or `Buffer`) added to the
39+
* trust store on top of the system roots — for TLS-inspecting proxies or
40+
* on-prem internal CAs. Honoured regardless of `checkServerCertificate`.
41+
* @internal SEA path only.
42+
*/
43+
customCaCert?: Buffer | string;
2144
}

0 commit comments

Comments
 (0)