Skip to content

feat(plugins): add Snowflake database driver (#1420)#1580

Open
xantiagoma wants to merge 5 commits into
TableProApp:mainfrom
xantiagoma:feat/snowflake-driver
Open

feat(plugins): add Snowflake database driver (#1420)#1580
xantiagoma wants to merge 5 commits into
TableProApp:mainfrom
xantiagoma:feat/snowflake-driver

Conversation

@xantiagoma
Copy link
Copy Markdown
Contributor

Summary

Adds a Snowflake database driver plugin, addressing #1420.

The driver speaks the Snowflake connector REST protocol (/session/v1/login-request + /queries/v1/query-request) — the same wire protocol the official drivers use — and supports every authentication method from the issue:

  • Username & password, including MFA TOTP passcodes and MFA token caching (CLIENT_REQUEST_MFA_TOKEN), so a code is only needed once per token lifetime when the account allows caching
  • Key pair (.p8) via SNOWFLAKE_JWT, including encrypted keys (passphrase) and SPKI public-key fingerprints
  • External browser SSO (EXTERNALBROWSER) with a localhost callback listener for the IdP redirect
  • OAuth / programmatic access tokens
  • Optional prefill from the Snowflake CLI's ~/.snowflake/connections.toml / config.toml by connection name

Also implements session token renewal on expiry (390112), query cancellation via abort-request, encrypted (SSE-C) result-chunk download with gzip inflation, database/schema navigation with USE, DDL via GET_DDL, and a Snowflake SQL dialect (375 functions / 172 keywords / 43 data types harvested from the official SQL reference) for highlighting and completions. scripts/add-snowflake-to-xcode.rb wires the .tableplugin target, and the registry release workflow gets a snowflake case.

One protocol gotcha worth recording: /queries/v1/query-request silently rejects UPPERCASE UUIDs in requestId with an empty HTTP 400 (Swift's UUID().uuidString default), while the login endpoint accepts them — every official connector emits lowercase by language convention, so their code never mentions it.

The second commit adds two DEBUG-only development affordances (both compiled out of Release builds): TABLEPRO_ALLOW_UNSIGNED_PLUGINS=1 to load locally built plugins past the team-signature check, and a file-based keychain fallback when the build lacks an application identifier. Without these, contributors cannot run a plugin they build, since only CI holds the team certificate. Happy to drop or rework that commit if you prefer another approach.

Testing

  • Live-tested against a real Snowflake account: password, password+TOTP, and PAT authentication; schema/table browsing; 3.2B-row table pagination; full result sets via encrypted chunk downloads (7k+ rows in one query); query cancellation; reconnects and session persistence
  • swiftlint lint --strict clean on all changed files
  • DatabaseType package tests updated and passing (18 known types)
  • Pre-existing note: SQLCompletionProviderTests/testProviderAcceptsDatabaseType and testMySQLProviderTypes fail order-dependently when the autocomplete suites run together — reproduces identically on main, unrelated to this PR (can file a separate issue)

Checklist

  • Tests added or updated
  • CHANGELOG.md updated under [Unreleased]
  • Docs updated (docs/databases/snowflake.mdx + navigation)
  • User-facing strings localized
  • No SwiftLint violations (swiftformat skipped: the repo .swiftformat uses --ifdefindent, which current Homebrew swiftformat doesn't recognize)

Closes #1420

🤖 Generated with Claude Code

xantiagoma and others added 2 commits June 4, 2026 00:58
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e90b05ba2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

static let defaultPrimaryKeyColumn: String? = nil
static let structureColumnFields: [StructureColumnField] = [.name, .type, .nullable, .defaultValue, .comment]
static let supportsCascadeDrop = true
static let supportsDropDatabase = true
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Disable drop-database support or implement it

When the Snowflake metadata advertises database dropping, the app can enable the database-delete flow for Snowflake connections, but SnowflakePluginDriver does not override dropDatabase(name:), so it falls back to the PluginDatabaseDriver default that throws “Drop database is not supported.” Either implement DROP DATABASE for this driver or set this capability (and the mirrored CloudDefaults flag) to false so users are not offered an action that always fails.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — implemented createDatabase/dropDatabase (plus the create-database form spec) in aabf4c7, mirroring the BigQuery driver: CREATE DATABASE / DROP DATABASE IF EXISTS with quoted identifiers.

@xantiagoma
Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA.

github-actions Bot added a commit that referenced this pull request Jun 4, 2026
Signed-off-by: Santiago Montoya A. <xantiagoma@gmail.com>
@xantiagoma
Copy link
Copy Markdown
Contributor Author

Triage of the macOS App Tests failure on this PR — none of the failures originate here:

Will update the branch from main once #1586 lands to get a clean run.

🤖 Generated with Claude Code

xantiagoma and others added 2 commits June 4, 2026 18:30
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… the Snowflake driver

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.

feat: Support Snowflake

1 participant