Skip to content

[PECOBLR-676] passing session params in open session request instead of SET commands#283

Merged
samikshya-db merged 2 commits intodatabricks:mainfrom
sreekanth-db:query-tags-integration
Aug 22, 2025
Merged

[PECOBLR-676] passing session params in open session request instead of SET commands#283
samikshya-db merged 2 commits intodatabricks:mainfrom
sreekanth-db:query-tags-integration

Conversation

@sreekanth-db
Copy link
Collaborator

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

Description

This PR refactors session parameter handling in the Go SQL Connector to align with other Databricks drivers (Java, Python). Previously, session parameters were set using SET statements after connection establishment, which was inefficient and inconsistent with other drivers. This new implementation also supports usage of QUERY_TAGS session parameter. Query Tags allow users to attach key-value pairs to SQL executions that appear in the system.query.history table.

Changes Made:

  1. Refactored Session Parameter Flow (connector.go):

    • Before: Session parameters were sent via SET statements after OpenSession
    • After: Session parameters are passed directly to TOpenSessionReq.Configuration during session creation
    • Benefit: Aligns with Java and Python drivers, and improves performance
  2. Created Example (examples/query_tags/main.go):

    • Demonstrates the usage of Query Tags
  3. Enhanced Unit Tests (internal/config/config_test.go):

    • Added QUERY_TAGS to DSN parsing test to verify parameter extraction

Change from User Perspective:

The key difference is in error timing: Previously, invalid session parameters would fail during connection establishment (SET command execution), but now they fail during the first query execution. This happens because the Databricks backend uses lazy validation - it accepts session parameters during connection but validates them only when the first query is executed. This matches Python driver behavior.

Query tags usage example:

connector, err := dbsql.NewConnector(
    dbsql.WithSessionParams(map[string]string{
        "timezone":   "America/Sao_Paulo",
        "ansi_mode":  "true",
        "QUERY_TAGS": "team:engineering",
    }),
)

How is this tested?

  • Unit tests
  • Manually

Testing Details:

Unit Tests:

  • Enhanced DSN parsing tests to verify session parameter extraction for query tags
  • All existing tests pass with the new implementation

Manual Testing:

  • Verified session parameters including query tags work correctly with real backend using the created example

Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
@sreekanth-db sreekanth-db changed the title passing session params in open session request instead of SET commands [PECOBLR-676] passing session params in open session request instead of SET commands Aug 8, 2025
@samikshya-db samikshya-db merged commit 5f3e28b into databricks:main Aug 22, 2025
2 of 3 checks passed
atzoum pushed a commit to rudderlabs/sqlconnect-go that referenced this pull request Feb 10, 2026
….8.0 to 1.9.0 (#431)

Bumps
[github.com/databricks/databricks-sql-go](https://github.com/databricks/databricks-sql-go)
from 1.8.0 to 1.9.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/databricks/databricks-sql-go/releases">github.com/databricks/databricks-sql-go's
releases</a>.</em></p>
<blockquote>
<h2>v1.9.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Added support for query tags</li>
<li><code>databricks/databricks-sql-go#283</code></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/databricks/databricks-sql-go/compare/v1.8.0...v1.9.0">https://github.com/databricks/databricks-sql-go/compare/v1.8.0...v1.9.0</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/databricks/databricks-sql-go/blob/main/CHANGELOG.md">github.com/databricks/databricks-sql-go's
changelog</a>.</em></p>
<blockquote>
<h2>v1.9.0 (2025-09-17)</h2>
<ul>
<li>Added support for query tags</li>
<li><code>databricks/databricks-sql-go#283</code></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/databricks/databricks-sql-go/commit/9cef5b704a6a3d5b29daf921b2ad159e471867ff"><code>9cef5b7</code></a>
Prepare for v1.9.0 release (<a
href="https://redirect.github.com/databricks/databricks-sql-go/issues/285">#285</a>)</li>
<li><a
href="https://github.com/databricks/databricks-sql-go/commit/c256716c926facfb14aa2798c8175c679ffe9530"><code>c256716</code></a>
Prepare for v1.9.0 release</li>
<li><a
href="https://github.com/databricks/databricks-sql-go/commit/5f3e28bf67ec207c09fcf5dc7475d80ce2c469b3"><code>5f3e28b</code></a>
[PECOBLR-676] passing session params in open session request instead of
SET c...</li>
<li><a
href="https://github.com/databricks/databricks-sql-go/commit/d7ebf01bed591b30bfae04252e1c54cd63e013f4"><code>d7ebf01</code></a>
unit test for query tags</li>
<li><a
href="https://github.com/databricks/databricks-sql-go/commit/ceaf079f73d0a6e5635d3567cc0277060f961b04"><code>ceaf079</code></a>
passing session params in open session request</li>
<li><a
href="https://github.com/databricks/databricks-sql-go/commit/631401e1c0c5d569c467eeaf3fcca1d8b351d650"><code>631401e</code></a>
add log for cloud fetch speed (<a
href="https://redirect.github.com/databricks/databricks-sql-go/issues/281">#281</a>)</li>
<li>See full diff in <a
href="https://github.com/databricks/databricks-sql-go/compare/v1.8.0...v1.9.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/databricks/databricks-sql-go&package-manager=go_modules&previous-version=1.8.0&new-version=1.9.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

3 participants

Comments