Skip to content

Conversation

@sreekanth-db
Copy link
Contributor

@sreekanth-db sreekanth-db commented Aug 8, 2025

Description

This PR adds support for passing session parameters during session creation in the Node.js SQL Driver. Previously, there was no direct API to forward session configuration during openSession. With this change, callers can provide a configuration map (e.g., QUERY_TAGS, ansi_mode) that is forwarded to Thrift TOpenSessionReq.configuration. This change allows users to pass query tags as well, which allow users to attach key-value pairs to SQL executions that appear in the system.query.history table.

Changes Made

  1. API (lib/contracts/IDBSQLClient.ts)

    • Added configuration?: { [key: string]: string } to OpenSessionRequest.
  2. Implementation (lib/DBSQLClient.ts)

    • openSession() now forwards request.configuration to Thrift via TOpenSessionReq.configuration
  3. Example (examples/session_params.js)

    • Demonstrates passing session params (QUERY_TAGS, ansi_mode etc.) via openSession({ configuration }).

Query Tags usage example

const { DBSQLClient } = require('@databricks/sql');

const client = new DBSQLClient();
await client.connect({ host, path, token });

const session = await client.openSession({
  configuration: {
    QUERY_TAGS: 'team:engineering,test:session-params,driver:node',
    ansi_mode: 'false',
  },
});

How is this tested?

  • Unit tests
  • E2E tests
  • Manually

Testing Details

  • Unit: Verified that configuration is forwarded to TOpenSessionReq.configuration. Ran the remaining unit suite; all passing.
  • E2E: Updated tests to include QUERY_TAGS in openSession({ configuration })
  • Manual: Executed examples/session_params.js against a real backend; returned expected result.

Signed-off-by: Sreekanth Vadigi <[email protected]>
@samikshya-db samikshya-db merged commit a85ec43 into databricks:main Aug 22, 2025
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants