Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Preserve wide negative DECIMAL values exactly with `preserveBigNumericPrecision: true`, including nested arrays and structs, on both backends. The default number conversion is unchanged.
- Kernel backend: `port` is passed to the kernel as is, so a custom port works over HTTPS as on Thrift. IPv6 hosts need brackets, an invalid port or host fails with a `ParameterError`, and the published `@databricks/databricks-sql-kernel-*` native packages must be bumped to a release that includes databricks/databricks-sql-kernel#505, since older packages ignore `port`.
- Honor client and per-statement `useLZ4Compression` in the kernel backend. The platform-specific `@databricks/databricks-sql-kernel-*` native packages must be bumped to a release that includes databricks/databricks-sql-kernel#511.
- Release completed Thrift CloudFetch body-reader listeners so idle connections do not retain downloaded result buffers.
- **Behavior change:** Thrift `getSchema()` and `getResultMetadata().schema` return `{ columns: [] }` for statements without output columns when Arrow metadata has no fields. Check `columns.length` before indexing. `getMetadata()` and responses without Arrow metadata (including `arrowEnabled: false` and older protocols) retain the `Result STRING` placeholder. (#651)
- Fix `fetchAll()` and `fetchChunk()` hanging on column-based results with an empty or missing schema. (#651)
Expand Down
28 changes: 14 additions & 14 deletions CONNECTION_PARAMETERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,19 @@ telemetry implementation, so only the options explicitly forwarded by

## Per-statement options (`session.executeStatement(sql, options)`)

| Option | Type | Thrift | Kernel | Default Value | Note |
| ------------------------- | ------------------------------------------------------- | :----: | :----: | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `queryTimeout` | `number \| bigint \| Int64` | ✅ | ❌ | — | Thrift sends this server-side timeout for Compute clusters. Kernel ignores it; SQL Warehouses use `STATEMENT_TIMEOUT`. |
| `runAsync` | `boolean` | ❌ | ✅ | — / `false` | Thrift always sends asynchronously and ignores the option. Kernel `false`/omitted uses direct execution; `true` submits and polls. This execute option is not deprecated. |
| `maxRows` | `number \| bigint \| Int64 \| null` | ✅ | ❌ | `100000` / — | Thrift uses it for the initial Direct Results row count; `null` disables Direct Results. Kernel does not retain or forward the supplied value. |
| `useCloudFetch` | `boolean` | ✅ | ❌ | `true` / — | Kernel logs and ignores this per-statement hint; Kernel result fetching owns its CloudFetch behavior. |
| `useLZ4Compression` | `boolean` | ✅ | ❌ | `true` / — | Thrift uses it when supported and when the result is not CloudFetch. Kernel owns and auto-detects result compression. |
| `stagingAllowedLocalPath` | `string \| string[]` | ✅ | ❌ | — | Local allowlist for Thrift volume/staging operations. Kernel volume operations are unsupported. |
| `namedParameters` | `Record<string, DBSQLParameter \| DBSQLParameterValue>` | ✅ | ✅ | — | Named SQL parameters. Cannot be combined with non-empty `ordinalParameters`. Thrift requires a protocol that supports parameterized queries. |
| `ordinalParameters` | `Array<DBSQLParameter \| DBSQLParameterValue>` | ✅ | ✅ | — | Positional SQL parameters. Cannot be combined with non-empty `namedParameters`. |
| `queryTags` | `Record<string, string \| null \| undefined>` | ✅ | ✅ | — | Serialized into the per-statement `query_tags` conf overlay on both. |
| `rowLimit` | `number` | ❌ | ✅ | — | Kernel-only server-side row cap. Thrift logs and ignores it. |
| `statementConf` | `Record<string, string>` | ❌ | ✅ | — | Kernel-only per-statement Spark conf overlay. Structured `queryTags` overwrite its `query_tags` key when non-empty. |
| Option | Type | Thrift | Kernel | Default Value | Note |
| ------------------------- | ------------------------------------------------------- | :----: | :----: | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `queryTimeout` | `number \| bigint \| Int64` | ✅ | ❌ | — | Thrift sends this server-side timeout for Compute clusters. Kernel ignores it; SQL Warehouses use `STATEMENT_TIMEOUT`. |
| `runAsync` | `boolean` | ❌ | ✅ | — / `false` | Thrift always sends asynchronously and ignores the option. Kernel `false`/omitted uses direct execution; `true` submits and polls. This execute option is not deprecated. |
| `maxRows` | `number \| bigint \| Int64 \| null` | ✅ | ❌ | `100000` / — | Thrift uses it for the initial Direct Results row count; `null` disables Direct Results. Kernel does not retain or forward the supplied value. |
| `useCloudFetch` | `boolean` | ✅ | ❌ | `true` / — | Kernel logs and ignores this per-statement hint; Kernel result fetching owns its CloudFetch behavior. |
| `useLZ4Compression` | `boolean` | ✅ | ✅ | Client setting | Override the client setting for this statement. On Thrift, the option applies to inline results with CloudFetch disabled. |
| `stagingAllowedLocalPath` | `string \| string[]` | ✅ | ❌ | — | Local allowlist for Thrift volume/staging operations. Kernel volume operations are unsupported. |
| `namedParameters` | `Record<string, DBSQLParameter \| DBSQLParameterValue>` | ✅ | ✅ | — | Named SQL parameters. Cannot be combined with non-empty `ordinalParameters`. Thrift requires a protocol that supports parameterized queries. |
| `ordinalParameters` | `Array<DBSQLParameter \| DBSQLParameterValue>` | ✅ | ✅ | — | Positional SQL parameters. Cannot be combined with non-empty `namedParameters`. |
| `queryTags` | `Record<string, string \| null \| undefined>` | ✅ | ✅ | — | Serialized into the per-statement `query_tags` conf overlay on both. |
| `rowLimit` | `number` | ❌ | ✅ | — | Kernel-only server-side row cap. Thrift logs and ignores it. |
| `statementConf` | `Record<string, string>` | ❌ | ✅ | — | Kernel-only per-statement Spark conf overlay. Structured `queryTags` overwrite its `query_tags` key when non-empty. |

## Metadata-operation request parameters

Expand All @@ -244,7 +244,7 @@ session parameter surface.

Thrift-only capabilities include custom/token-provider authentication, custom
OAuth persistence, SOCKS4 user IDs, authenticated/driver-buffer telemetry knobs,
query timeout, Direct Results `maxRows`, per-statement CloudFetch/LZ4 hints, and
query timeout, Direct Results `maxRows`, per-statement CloudFetch hints, and
volume operations.

Kernel-only capabilities include connection-pool sizing, proxy bypass hosts,
Expand Down
2 changes: 1 addition & 1 deletion KERNEL_REV
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a29235cbea9532efa5572ebff010045583a19cbe
eb04529fd036771f031446cffabd20ff16e5c50a
45 changes: 13 additions & 32 deletions lib/kernel/KernelSessionBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,22 @@ export default class KernelSessionBackend implements ISessionBackend {
* never forwarded to the kernel and never applied as a client-side
* deadline — see the note in `executeStatement`;
* - `rowLimit` → `rowLimit` (kernel-only server-side row cap);
* - `useLZ4Compression` → `lz4Compression`, with the client setting as the default;
* - `queryTags` → serialised into the conf overlay's reserved
* `query_tags` key (the same wire shape Thrift's `serializeQueryTags`
* produces), merged with any explicit `statementConf`.
*
* Still rejected (genuinely unsupported on kernel, rather than silently
* dropped): `useCloudFetch` (governed by the kernel `ResultConfig`, not a
* per-statement knob), `useLZ4Compression` (kernel owns result compression),
* and `stagingAllowedLocalPath` (volume operations). `maxRows` is applied by
* the facade at fetch time, so it is intentionally not handled here.
* The kernel backend logs a warning when a statement supplies `useCloudFetch`
* or `stagingAllowedLocalPath` and ignores those hints. The session controls
* CloudFetch through `ResultConfig`. The facade applies `maxRows` at fetch time.
*/
public async executeStatement(statement: string, options: ExecuteStatementOptions): Promise<IOperationBackend> {
this.failIfClosed();

// Per-statement options the kernel backend doesn't honour are treated as
// NO-OPs (logged at warn), not errors — so call sites written for the Thrift
// backend are drop-in on the kernel path. These are perf/format hints the
// kernel governs internally (useCloudFetch / useLZ4Compression) or a feature
// kernel governs internally (useCloudFetch) or a feature
// it doesn't expose yet (staging); ignoring them cannot change query results.
// NB: parameter binding (compound/BINARY) is deliberately NOT no-op'd — a
// dropped param would silently change results, so it still throws.
Expand All @@ -172,14 +171,6 @@ export default class KernelSessionBackend implements ISessionBackend {
'kernel executeStatement: ignoring per-statement `useCloudFetch` — result fetching is governed by the kernel result configuration (no-op on kernel).',
);
}
if (options.useLZ4Compression !== undefined) {
this.context
.getLogger()
.log(
LogLevel.warn,
'kernel executeStatement: ignoring per-statement `useLZ4Compression` — result compression is governed by the kernel (no-op on kernel).',
);
}
if (options.stagingAllowedLocalPath !== undefined) {
this.context
.getLogger()
Expand Down Expand Up @@ -224,6 +215,7 @@ export default class KernelSessionBackend implements ISessionBackend {
// execution. So `queryTimeout` is neither forwarded to the kernel nor used as
// a client-side deadline.

const execOptions = this.buildExecuteOptions(options);
if (!runAsync) {
// DEFAULT — directResults (the Thrift/JDBC model). The kernel's
// `executeStatementDirect` runs ExecuteStatement with a bounded server
Expand All @@ -234,13 +226,9 @@ export default class KernelSessionBackend implements ISessionBackend {
// query stays cancellable via `op.cancel()` and `close()` is a clean
// release (no client-side drive-to-terminal). Fire-and-forget DDL/DML
// commits because the server runs it inline during the POST.
const execOptions = this.buildExecuteOptions(options);
let direct: KernelStatement | KernelNativeAsyncStatement;
try {
direct =
execOptions === undefined
? await this.connection.executeStatementDirect(statement)
: await this.connection.executeStatementDirect(statement, execOptions);
direct = await this.connection.executeStatementDirect(statement, execOptions);
} catch (err) {
throw this.logAndMapError('executeStatement', err);
}
Expand All @@ -264,13 +252,9 @@ export default class KernelSessionBackend implements ISessionBackend {

// Async path: submit (`wait_timeout=0s`) returns a pending handle the
// backend polls. (`queryTimeout` is a no-op on kernel — see the note above.)
const execOptions = this.buildExecuteOptions(options);
let asyncStatement;
try {
asyncStatement =
execOptions === undefined
? await this.connection.submitStatement(statement)
: await this.connection.submitStatement(statement, execOptions);
asyncStatement = await this.connection.submitStatement(statement, execOptions);
} catch (err) {
throw this.logAndMapError('executeStatement', err);
}
Expand All @@ -283,12 +267,7 @@ export default class KernelSessionBackend implements ISessionBackend {
});
}

/**
* Translate the public `ExecuteStatementOptions` into the kernel napi
* `ExecuteOptions`, returning `undefined` when nothing is set so the
* no-options call shape (`executeStatement(sql)`) is preserved.
*/
private buildExecuteOptions(options: ExecuteStatementOptions): KernelNativeExecuteOptions | undefined {
private buildExecuteOptions(options: ExecuteStatementOptions): KernelNativeExecuteOptions {
// Positional (`?`) and named (`:name`) parameters are mutually exclusive —
// the kernel binds one placeholder style per statement. Use the SAME error
// type and message as the Thrift backend (`ThriftSessionBackend`) so a
Expand All @@ -299,7 +278,9 @@ export default class KernelSessionBackend implements ISessionBackend {
throw new ParameterError('Driver does not support both ordinal and named parameters.');
}

const execOptions: KernelNativeExecuteOptions = {};
const execOptions: KernelNativeExecuteOptions = {
lz4Compression: options.useLZ4Compression ?? this.context.getConfig().useLZ4Compression,
Comment thread
aakash-saravanan-db marked this conversation as resolved.
Resolved
Comment thread
oss-reviewer-bot[bot] marked this conversation as resolved.
Resolved

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High — The driver now sends lz4Compression, but every platform package is still pinned to 1.5.0, so installed users get a kernel that ignores the option. The CHANGELOG documents this and the earlier port change did the same. Bump the pins and lockfile once the kernel release with databricks/databricks-sql-kernel#511 is published.

🔀 Found by GPT-6.1 Sol · confirmed by the judge

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. The source pin now selects the merged kernel, but that does not update the published native packages. This remains open until supporting packages are published, all eight platform pins and the lockfile are updated, and the installed or bundled pair is validated.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open at 366e37d: all eight platform pins remain 1.5.0 (package.json:95-102), and the lockfile hasn't been updated.

};
// Raw binding preserves qualified SQL types such as INTERVAL MONTH.
const rawParams = positionalParams ?? namedParams;
if (rawParams !== undefined) {
Expand Down Expand Up @@ -328,7 +309,7 @@ export default class KernelSessionBackend implements ISessionBackend {
}
}

return Object.keys(execOptions).length > 0 ? execOptions : undefined;
return execOptions;
}

/** Wrap a napi metadata `Statement` (already terminal) as an operation backend. */
Expand Down
5 changes: 4 additions & 1 deletion native/kernel/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading