From feee62dd7fa5fa914007c62f83896240cf7a344c Mon Sep 17 00:00:00 2001 From: eric-wang-1990 Date: Wed, 22 Jul 2026 00:48:46 -0700 Subject: [PATCH 01/12] docs: add connection parameter reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add docs/connection-parameters.md — a grouped reference of every connection / session parameter the kernel accepts, mirroring the ADBC C# driver's parameter wiki. Each parameter lists its Rust field, Python kwarg, and Node.js option name alongside a description and the kernel-core default value. Groups: connection identity, auth (PAT / OAuth M2M / U2M), session defaults, HTTP client, proxy, TLS, result handling, logging, server-side session_conf (with the allowlisted keys), and transport. Values sourced from src/config.rs (defaults), pyo3/src/session.rs (Python kwargs), and napi/index.d.ts (Node.js options). Also refresh the stale README intro (it still described the removed ADBC surface) and link the new reference from README and CLAUDE.md. Co-authored-by: Isaac Signed-off-by: eric-wang-1990 --- CLAUDE.md | 1 + README.md | 15 +- docs/connection-parameters.md | 335 ++++++++++++++++++++++++++++++++++ 3 files changed, 348 insertions(+), 3 deletions(-) create mode 100644 docs/connection-parameters.md diff --git a/CLAUDE.md b/CLAUDE.md index 7f52b18f..aaeee1a4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -150,4 +150,5 @@ E2E tests requiring a live Databricks connection are marked `#[ignore]` and run - [Databricks SQL Statement Execution API](https://docs.databricks.com/api/workspace/statementexecution) - [Apache Arrow Rust](https://docs.rs/arrow/latest/arrow/) - `docs/spec-v0.md` — v0 Kernel API spec +- `docs/connection-parameters.md` — connection / session parameter reference (all bindings) - `docs/migration-plan.md` — staged migration plan from ADBC to v0 diff --git a/README.md b/README.md index 9dd04201..0dd00aa1 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,11 @@ Rust client core for Databricks SQL — the shared engine intended to power the Databricks ODBC, Python, Go, and Node.js drivers. -The kernel is currently exposed via the [ADBC](https://arrow.apache.org/adbc/) -trait surface from `adbc_core`. A native (non-ADBC) Rust API and a stable C -ABI for ODBC/Go consumers are planned. +The kernel exposes a Databricks-native v0 async API (`Session` → +`Statement` → `ExecutedStatement` → `ResultStream`, plus a flat `Metadata` +surface) for direct Rust use, the PyO3 (Python) and napi-rs (Node.js) +wrappers, and a C ABI for ODBC / Go consumers. See +[`docs/spec-v0.md`](docs/spec-v0.md) for the API spec. ## Status @@ -35,6 +37,13 @@ cargo test make check # fmt + clippy + tests ``` +## Configuration + +Every connection / session parameter — what it means, how it is named in +each binding (Rust, Python, Node.js), and its default value — is +documented in +[`docs/connection-parameters.md`](docs/connection-parameters.md). + ## License Apache 2.0. See [LICENSE](LICENSE) and [NOTICE.txt](NOTICE.txt). diff --git a/docs/connection-parameters.md b/docs/connection-parameters.md new file mode 100644 index 00000000..fcd73765 --- /dev/null +++ b/docs/connection-parameters.md @@ -0,0 +1,335 @@ + + +# Connection Parameters + +Every configuration knob the Databricks SQL Kernel accepts, grouped by +concern, with its meaning and default value. + +The kernel is consumed through three surfaces, and each names the same +underlying knob slightly differently: + +| Surface | How parameters are supplied | +|---------|-----------------------------| +| **Rust** (`databricks-sql-kernel`) | Typed config structs on `SessionConfig` — one sub-struct per concern (`ConnectionConfig`, `AuthConfig`, `HttpConfig`, `TlsConfig`, `ProxyConfig`, `ResultConfig`, `DefaultOpts`, `LoggingConfig`), assembled and passed to `Session::open`. | +| **Python** (`databricks-sql-kernel` wheel) | Keyword arguments to `Session(host, http_path, **kwargs)`. | +| **Node.js** (`@databricks/databricks-sql-kernel`) | Fields on the `ConnectionOptions` object passed to `openSession(options)`. | + +Each table below lists the **Rust field**, the **Python kwarg**, and the +**Node.js option** for the same parameter, so wrapper authors and driver +users can cross-reference. A blank cell means that binding does not +expose the knob yet (the Rust core always does). + +> **Note on defaults.** The "Default" column is the kernel-core default +> from `src/config.rs`. Some bindings apply a binding-specific default +> that differs — those are called out in the notes under each table. + +--- + +## Table of contents + +- [Connection identity](#connection-identity) — host, warehouse, org +- [Authentication](#authentication) — PAT, OAuth M2M, OAuth U2M +- [Session defaults](#session-defaults) — catalog, schema, transactions +- [HTTP client](#http-client) — timeouts, pool size, retries, headers +- [Proxy](#proxy) +- [TLS / SSL](#tls--ssl) +- [Result handling](#result-handling) — CloudFetch, type rendering +- [Logging](#logging) +- [Server-side session configuration](#server-side-session-configuration) — `session_conf` +- [Transport](#transport) + +--- + +## Connection identity + +Required. Identifies the workspace and warehouse to connect to. + +| Rust (`ConnectionConfig`) | Python kwarg | Node.js (`ConnectionOptions`) | Description | Default | +|---|---|---|---|---| +| `host` | `host` | `hostName` | Workspace URL, e.g. `https://my-workspace.databricks.com`. Bare hostnames get `https://` prepended and any trailing `/` stripped. | **(required)** | +| `warehouse_id` | (parsed from `http_path`) | (parsed from `httpPath`) | Warehouse id, e.g. `abc123`. In Rust use `ConnectionConfig::from_http_path` to parse it out of a `/sql/1.0/warehouses/{id}` path; the bindings accept the full HTTP path directly. | **(required)** | +| `org_id` | (parsed from `http_path`) | (parsed from `httpPath`) | Workspace organization id for multi-tenant routing. Sent as the `x-databricks-org-id` header. Auto-populated from the `?o=` query parameter of the HTTP path. | `None` | + +**Notes** + +- Accepted HTTP-path forms: `/sql/1.0/warehouses/{id}` (canonical) and + `/sql/1.0/endpoints/{id}` (legacy, equivalent server-side), with or + without a leading `/`, and with an optional `?o={org_id}` suffix. +- Python / Node.js take `http_path` / `httpPath` and the kernel parses + the warehouse id and org id out of it. + +--- + +## Authentication + +Required. The kernel supports a personal access token and two OAuth 2.0 +flows. Select the flow with `auth_type` (Python) / `authMode` (Node.js), +or by choosing the `AuthConfig` variant (Rust). Omitting the selector +defaults to **PAT** when a token is supplied. + +### Personal access token (PAT) + +| Rust (`AuthConfig::Pat`) | Python kwarg | Node.js | Description | Default | +|---|---|---|---|---| +| `token` | `access_token` | `token` | Personal access token (`dapi…`). Must be non-empty. | **(required for PAT)** | + +### OAuth 2.0 machine-to-machine (M2M, client credentials) + +Service-principal auth. Select with `auth_type="oauth-m2m"` / `authMode: OAuthM2m`. + +| Rust (`AuthConfig::OAuthM2M`) | Python kwarg | Node.js | Description | Default | +|---|---|---|---|---| +| `client_id` | `client_id` | `oauthClientId` | OAuth client id. Must be non-empty. | **(required for M2M)** | +| `client_secret` | `client_secret` | `oauthClientSecret` | OAuth client secret. Must be non-empty. | **(required for M2M)** | +| `scopes` | `oauth_scopes` | `oauthScopes` | OAuth scopes to request. | `["all-apis"]` | +| `token_url_override` | `token_url` | | Token endpoint override. | OIDC discovery at `/.well-known/oauth-authorization-server` | + +### OAuth 2.0 user-to-machine (U2M, browser flow) + +Authorization code + PKCE. The kernel opens the user's browser and runs a +localhost listener for the callback. Select with `auth_type="oauth-u2m"` / +`authMode: OAuthU2m`. + +| Rust (`AuthConfig::OAuthU2M`) | Python kwarg | Node.js | Description | Default | +|---|---|---|---|---| +| `client_id` | `client_id` | `oauthClientId` | OAuth client id. | `"databricks-cli"` | +| `redirect_port` | `redirect_port` | `oauthRedirectPort` | Localhost port for the OAuth callback listener. | `8020` | +| `scopes` | `oauth_scopes` | `oauthScopes` | OAuth scopes. `offline_access` is needed for a refresh token (cached and refreshed transparently). | `["all-apis", "offline_access"]` | +| `token_url_override` | `token_url` | | Token endpoint override. | OIDC discovery | +| `callback_timeout` | `oauth_callback_timeout_secs` | | How long to wait for the user to complete the browser flow. | `120s` | + +**Notes** + +- Two further Rust variants exist but are **not** exposed by the bindings: + `AuthConfig::OAuthFederation` (RFC 8693 token exchange — reserved, + returns `InvalidArgument` until implemented) and `AuthConfig::External` + (a caller-supplied `TokenProvider` trait, a Rust-only escape hatch). +- The Node.js binding defaults the U2M client id to + `databricks-sql-connector` (rather than the core's `databricks-cli`). + +--- + +## Session defaults + +Optional. Per-session defaults applied to every statement. + +| Rust (`DefaultOpts`) | Python kwarg | Node.js | Description | Default | +|---|---|---|---|---| +| `catalog` | `catalog` | `catalog` | Default catalog for statements on this session (SEA `CreateSession.catalog`). | `None` (server default) | +| `schema` | `schema` | `schema` | Default schema for statements on this session (SEA `CreateSession.schema`). | `None` (server default) | +| `ignore_transactions` | | | When `true`, transaction-control calls (`set_autocommit(false)`, `commit()`, `rollback()`) are silently no-oped. Mirrors JDBC `IgnoreTransactions=1`. Set `false` to opt into real multi-statement transactions (Private Preview; requires catalog-managed tables). | `true` | + +--- + +## HTTP client + +Optional. Tunes timeouts, the connection pool, retry/backoff, and custom +headers. + +| Rust (`HttpConfig`) | Python kwarg | Node.js | Description | Default | +|---|---|---|---|---| +| `request_timeout` | | `socketTimeoutMs` | Per-request timeout (connect + body) — caps a single HTTP round-trip. | `120s` | +| `overall_timeout` | `retry_overall_timeout_secs` | `retryOverallTimeoutSecs` | Maximum total time across retries for one logical RPC. | `900s` | +| `pool_max_idle_per_host` | | `maxConnections` | Connection-pool size (max idle warm sockets per host). Raise for bursty concurrent workloads. | `100` | +| `retry_min_wait` | `retry_min_wait_secs` | `retryMinWaitSecs` | Minimum backoff between retries; also the floor for a server `Retry-After` and the base of exponential backoff (`min_wait × 2^attempt`). | `1s` | +| `retry_max_wait` | `retry_max_wait_secs` | `retryMaxWaitSecs` | Maximum backoff between retries; caps both the exponential backoff and a server `Retry-After`. | `60s` | +| `retry_max_retries` | `retry_max_attempts` | `retryMaxAttempts` | See note below on retries-vs-attempts. | `5` retries (`6` total attempts) | +| `custom_headers` | `http_headers` | `customHeaders` | Extra headers on every request. Ordered list of `(name, value)`; duplicates allowed. | `[]` (none) | + +**Notes** + +- **Retries vs. attempts.** The Rust `retry_max_retries` counts retries + *after* the first attempt (so `5` → 6 total attempts). The Python + `retry_max_attempts` and Node.js `retryMaxAttempts` are **total + attempts** (matching the connector's `_retry_stop_after_attempts_count` + and JDBC), converted internally as `retry_max_retries = max(0, attempts − 1)`. + Passing `0` or `1` both mean "one attempt, no retries". +- **Reserved headers.** `Authorization` and `x-databricks-org-id` in + `custom_headers` are silently dropped (with a warning) so auth and + multi-tenant routing can't be hijacked. A caller `User-Agent` is folded + into the effective UA rather than sent as a duplicate. +- The Node.js binding applies a binding-specific `maxConnections` default + of `100` when unset (matches the core). + +--- + +## Proxy + +Optional. Programmatic HTTP/HTTPS proxy. When unset, the kernel does not +configure a proxy and `reqwest`'s standard `HTTP_PROXY` / `HTTPS_PROXY` / +`NO_PROXY` environment-variable behaviour applies. Setting `url` +**overrides** those env vars. + +| Rust (`ProxyConfig`) | Python kwarg | Node.js (`ProxyInput`) | Description | Default | +|---|---|---|---|---| +| `url` | | `proxy.url` | Proxy endpoint, e.g. `http://proxy.corp.example.com:8080`. Must be `http://` or `https://`. | `None` (env-var behaviour) | +| `username` | | `proxy.username` | Proxy basic-auth username. Overrides credentials embedded in `url`. | `None` | +| `password` | | `proxy.password` | Proxy basic-auth password. Ignored unless `username` is set. Redacted in logs. | `None` | +| `bypass_hosts` | | `proxy.bypassHosts` | Comma-separated hosts/domains to bypass the proxy, e.g. `localhost,*.internal.corp,.example.com`. | `None` | + +**Notes** + +- The Python binding does not currently expose a programmatic proxy; + Python users rely on the `HTTP(S)_PROXY` environment variables. + +--- + +## TLS / SSL + +Optional. **All defaults are the most secure stance:** validate the +system trust store, require a valid chain, and verify hostnames. Every +non-default field is a *relaxation* — use for dev / on-prem boxes, never +against production. + +| Rust (`TlsConfig`) | Python kwarg | Node.js | Description | Default | +|---|---|---|---|---| +| `custom_ca_cert` | `tls_ca_cert` | `customCaCert` | PEM-encoded CA cert bytes added to the trust store on top of system roots (for TLS-inspecting proxies or internal CAs). Multi-cert bundles (root + intermediate) are supported. | `None` | +| `accept_self_signed` | `tls_skip_verify` | `checkServerCertificate` (inverted) | Accept self-signed / untrusted / expired certs. **Disables all chain validation** — dev only. | `false` (validation on) | +| `skip_hostname_verification` | `tls_skip_hostname_verify` | `checkServerCertificateHostname` (inverted) | Skip only the cert-hostname-vs-SNI check while still validating the chain (e.g. connecting via an IP literal). | `false` (check on) | +| `client_cert_pem` | `tls_client_cert` | `clientCertPem` | PEM-encoded client certificate for mutual TLS (mTLS). Must be set together with the key. | `None` | +| `client_key_pem` | `tls_client_key` | `clientKeyPem` | PEM-encoded private key for the mTLS client cert. Supply PKCS#8 for portability across TLS backends. Must be set together with the cert. | `None` | + +**Notes** + +- The Node.js knobs are **positive** booleans: `checkServerCertificate` + (default `true`) is the master verify toggle — setting it `false` + disables chain validation *and* subsumes the hostname check; + `checkServerCertificateHostname` (default `true`) toggles only the + hostname check. These map to the inverse of the Rust + `accept_self_signed` / `skip_hostname_verification` fields. +- Setting only one of `client_cert_pem` / `client_key_pem` is rejected at + `Session::open` with `InvalidArgument`. + +--- + +## Result handling + +Optional. Tunes CloudFetch and how result columns are rendered. + +| Rust (`ResultConfig`) | Python kwarg | Node.js | Description | Default | +|---|---|---|---|---| +| `cloudfetch_enabled` | | | Opt into CloudFetch (cloud-storage-backed download of large results via presigned URLs). Set `false` to force the inline-Arrow path (mirrors JDBC `EnableQueryResultDownload=0`). | `true` | +| `cloudfetch_link_prefetch_window` | | | Number of presigned URLs to prefetch ahead of the consumer. | `10` | +| `cloudfetch_max_chunks_in_memory` | | | Max decompressed CloudFetch chunks held in memory at once (bounds download parallelism and peak RSS). | `16` | +| `inline_max_chunks_in_memory` | | | Prefetch window for the inline-Arrow path (used when CloudFetch is disabled). `1` disables prefetching (strict lazy fetch). | `4` | +| `complex_types_as_json` | `complex_types_as_json` | `complexTypesAsJson` | Render complex columns (`ARRAY` / `MAP` / `STRUCT` / `VARIANT` / `GEOMETRY` / `GEOGRAPHY`) as compact JSON strings instead of native Arrow nested types. | `false` | +| `intervals_as_string` | `intervals_as_string` | `intervalsAsString` | Render `INTERVAL` / `DURATION` columns as canonical Databricks text (e.g. `"Y-M"`, `"D HH:MM:SS.nnnnnnnnn"`) instead of native Arrow interval types. Needed for pyarrow consumers, which can't decode Arrow `month_interval`. | `false` | + +**Notes** + +- The CloudFetch tuning knobs are Rust-core only today; the bindings + expose the two result-rendering toggles (`complex_types_as_json`, + `intervals_as_string`) but inherit the CloudFetch defaults. + +--- + +## Logging + +Optional. Rust-core only — bindings install their own log bridges (the +Node.js binding via `initKernelLogging`, the Python binding via its +`logging` module). + +| Rust (`LoggingConfig`) | Description | Default | +|---|---|---| +| `filter` | Log filter, e.g. `databricks_sql_kernel=debug`. When `None`, the kernel honours the `RUST_LOG` environment variable. | `None` (uses `RUST_LOG`) | +| `file` | File to write logs to. When `None`, logs go to stderr. | `None` (stderr) | + +--- + +## Server-side session configuration + +The `session_conf` (Rust / Python) / `sessionConf` (Node.js) map carries +**server-bound** SQL / Spark configuration, forwarded to SEA +`session_confs` and applied for every statement on the session. + +| Rust / Python | Node.js | Description | Default | +|---|---|---|---| +| `session_conf` | `sessionConf` | Map of server-side session-config key → value. | `{}` (empty) | + +Keys are matched **case-insensitively** against a kernel allowlist and +**uppercased** before being sent (the server echoes them uppercase, so +`SET`-readback matches). Keys not in the allowlist are **dropped with a +warning**. + +### Allowed keys + +Sourced from the [Databricks SQL configuration-parameters +reference](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-parameters) +plus the additional keys the Java driver accepts. See that page for the +per-parameter meaning and accepted values. + +| Key | Notes | +|---|---| +| `ANSI_MODE` | Enable/disable ANSI SQL behaviour. | +| `CAN_CLOUD_DOWNLOAD` | Kernel-synthesised from `ResultConfig::cloudfetch_enabled = false`; a user-supplied value (any casing) wins. | +| `COLLATION` | Default collation. | +| `ENABLE_PHOTON` | Toggle the Photon engine. | +| `LEGACY_TIME_PARSER_POLICY` | Legacy datetime parsing behaviour. | +| `MAX_FILE_PARTITION_BYTES` | Max bytes per file partition. | +| `QUERY_TAGS` | Query tags (comma-separated `key:value`). | +| `READ_ONLY_EXTERNAL_METASTORE` | Treat the external metastore as read-only. | +| `STATEMENT_TIMEOUT` | Server-side per-statement timeout (seconds). This is the real query-timeout knob. | +| `TIMEZONE` | Session time zone, e.g. `UTC`. | +| `USE_CACHED_RESULT` | Toggle result caching. | + +### Case-sensitive Spark confs + +Dotted `spark.*` confs are matched case-insensitively but sent +**verbatim** (Spark conf keys are case-sensitive and must not be +uppercased): + +| Key | Notes | +|---|---| +| `spark.sql.thriftserver.metadata.metricview.enabled` | When `"true"`, `SHOW TABLES` returns `METRIC_VIEW` rows and `getColumns` surfaces `measure` columns. Mirrors JDBC `EnableMetricViewMetadata` (default off). | + +**Notes** + +- Boolean-valued keys should use the exact strings `"true"` / `"false"`; + other forms (`"True"`, `"yes"`, `"1"`) are undefined server-side. The + kernel does not pre-validate values — it trusts the supplied + `session_conf` and forwards values as-is. + +--- + +## Transport + +Optional. Wire-protocol selection. Rust-core only. + +| Rust (`TransportMode`) | Description | Default | +|---|---|---| +| `transport` | Wire protocol. v0 supports `SeaRest` (Statement Execution API over REST) only; the enum is reserved to grow `SeaGrpc` / `Thrift` in v1+. | `SeaRest` | + +--- + +## Per-statement options + +The parameters above are **session-level**. A few knobs are set +per-statement rather than per-session (via `StatementSpec` in Rust and +`ExecuteOptions` in the Node.js binding): + +- `statement_conf` / `statementConf` — per-statement Spark-conf overlay, + merged on top of the session `session_conf` (statement wins on key + collisions). +- `query_tags` / `queryTags` — convenience over `statement_conf`'s + `query_tags` key. +- `row_limit` / `rowLimit` — server-side cap on rows returned (SEA + `row_limit`), independent of any SQL `LIMIT`. +- Bound parameters — positional (`?`) and named (`:name`) query + parameters. + +See `docs/spec-v0.md` and the `StatementSpec` docs for the full +per-statement surface. From d52d8086b378c6e2df62dffd802b11a761c9e09a Mon Sep 17 00:00:00 2001 From: eric-wang-1990 Date: Wed, 22 Jul 2026 00:53:27 -0700 Subject: [PATCH 02/12] =?UTF-8?q?docs:=20address=20review=20=E2=80=94=20Ru?= =?UTF-8?q?st-only,=20inline=20in=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per review feedback: - Move the parameter reference into README.md instead of a separate docs/ file (remove docs/connection-parameters.md). - Scope it to the Rust SessionConfig surface only; drop the Python / Node.js binding columns. - Revert the CLAUDE.md references link (no separate doc to point at). Co-authored-by: Isaac Signed-off-by: eric-wang-1990 --- CLAUDE.md | 1 - README.md | 170 ++++++++++++++++- docs/connection-parameters.md | 335 ---------------------------------- 3 files changed, 166 insertions(+), 340 deletions(-) delete mode 100644 docs/connection-parameters.md diff --git a/CLAUDE.md b/CLAUDE.md index aaeee1a4..7f52b18f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -150,5 +150,4 @@ E2E tests requiring a live Databricks connection are marked `#[ignore]` and run - [Databricks SQL Statement Execution API](https://docs.databricks.com/api/workspace/statementexecution) - [Apache Arrow Rust](https://docs.rs/arrow/latest/arrow/) - `docs/spec-v0.md` — v0 Kernel API spec -- `docs/connection-parameters.md` — connection / session parameter reference (all bindings) - `docs/migration-plan.md` — staged migration plan from ADBC to v0 diff --git a/README.md b/README.md index 0dd00aa1..900ea8b9 100644 --- a/README.md +++ b/README.md @@ -39,10 +39,172 @@ make check # fmt + clippy + tests ## Configuration -Every connection / session parameter — what it means, how it is named in -each binding (Rust, Python, Node.js), and its default value — is -documented in -[`docs/connection-parameters.md`](docs/connection-parameters.md). +A session is configured with a `SessionConfig`, assembled from typed +sub-structs (one per concern) and passed to `Session::open`. Every +parameter, its meaning, and its default value is listed below, grouped +by the struct it lives on. + +`ConnectionConfig` and `AuthConfig` are **required**; the rest are +optional and fall back to the defaults shown. + +### `ConnectionConfig` — connection identity (required) + +Construct via `ConnectionConfig::new(host, warehouse_id)` or +`ConnectionConfig::from_http_path(host, http_path)` (which parses the +warehouse id and org id out of a `/sql/1.0/warehouses/{id}` path). + +| Field | Description | Default | +|-------|-------------|---------| +| `host` | Workspace URL, e.g. `https://my-workspace.databricks.com`. Bare hostnames get `https://` prepended and any trailing `/` stripped. | **(required)** | +| `warehouse_id` | Warehouse id, e.g. `abc123`. Accepts `/sql/1.0/warehouses/{id}` and legacy `/sql/1.0/endpoints/{id}` forms via `from_http_path`. | **(required)** | +| `org_id` | Workspace organization id for multi-tenant routing; sent as the `x-databricks-org-id` header. Auto-populated from the `?o=` query parameter of the HTTP path. | `None` | + +### `AuthConfig` — authentication (required) + +An enum; pick one variant. Use the validating constructors +(`AuthConfig::pat`, `::oauth_m2m`, `::oauth_u2m`). + +**`Pat`** — personal access token: + +| Field | Description | Default | +|-------|-------------|---------| +| `token` | Personal access token (`dapi…`). Must be non-empty. | **(required)** | + +**`OAuthM2M`** — machine-to-machine (client credentials, service principal): + +| Field | Description | Default | +|-------|-------------|---------| +| `client_id` | OAuth client id. Must be non-empty. | **(required)** | +| `client_secret` | OAuth client secret. Must be non-empty. | **(required)** | +| `scopes` | OAuth scopes to request. | `["all-apis"]` | +| `token_url_override` | Token endpoint override. | OIDC discovery at `/.well-known/oauth-authorization-server` | + +**`OAuthU2M`** — user-to-machine (authorization code + PKCE, browser flow): + +| Field | Description | Default | +|-------|-------------|---------| +| `client_id` | OAuth client id. | `"databricks-cli"` | +| `redirect_port` | Localhost port for the OAuth callback listener. | `8020` | +| `scopes` | OAuth scopes. `offline_access` is required to receive a refresh token (cached and refreshed transparently). | `["all-apis", "offline_access"]` | +| `token_url_override` | Token endpoint override. | OIDC discovery | +| `callback_timeout` | How long to wait for the user to complete the browser flow. | `120s` | + +Two further variants are reserved but not usable in v0: +`OAuthFederation` (RFC 8693 token exchange — returns `InvalidArgument` +until implemented) and `External` (a caller-supplied `TokenProvider`). + +### `DefaultOpts` — session defaults (optional) + +| Field | Description | Default | +|-------|-------------|---------| +| `catalog` | Default catalog for statements on this session. | `None` (server default) | +| `schema` | Default schema for statements on this session. | `None` (server default) | +| `ignore_transactions` | When `true`, transaction-control calls (`set_autocommit(false)`, `commit()`, `rollback()`) are silently no-oped. Mirrors JDBC `IgnoreTransactions=1`. Set `false` to opt into real multi-statement transactions (Private Preview; requires catalog-managed tables). | `true` | + +### `HttpConfig` — HTTP client (optional) + +| Field | Description | Default | +|-------|-------------|---------| +| `request_timeout` | Per-request timeout (connect + body). | `120s` | +| `overall_timeout` | Maximum total time across retries for one logical RPC. | `900s` | +| `pool_max_idle_per_host` | Connection-pool size (max idle warm sockets per host). Raise for bursty concurrent workloads. | `100` | +| `retry_min_wait` | Minimum backoff between retries; also the floor for a server `Retry-After` and the base of exponential backoff (`min_wait × 2^attempt`). | `1s` | +| `retry_max_wait` | Maximum backoff between retries; caps both the exponential backoff and a server `Retry-After`. | `60s` | +| `retry_max_retries` | Max retries **after** the first attempt — a request is tried at most `retry_max_retries + 1` times. | `5` (→ 6 total attempts) | +| `custom_headers` | Extra headers on every request; an ordered `Vec<(String, String)>` (duplicates allowed). `Authorization` / `x-databricks-org-id` are silently dropped (reserved); a `User-Agent` is folded into the effective UA. | `[]` | + +### `ProxyConfig` — HTTP/HTTPS proxy (optional) + +When `url` is `None`, the kernel does not configure a proxy and +`reqwest`'s standard `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY` env-var +behaviour applies. Setting `url` **overrides** those env vars. + +| Field | Description | Default | +|-------|-------------|---------| +| `url` | Proxy endpoint, e.g. `http://proxy.corp.example.com:8080`. Must be `http://` or `https://`. | `None` (env-var behaviour) | +| `username` | Proxy basic-auth username. Overrides credentials embedded in `url`. | `None` | +| `password` | Proxy basic-auth password. Ignored unless `username` is set. Redacted in `Debug`. | `None` | +| `bypass_hosts` | Comma-separated hosts/domains to bypass the proxy, e.g. `localhost,*.internal.corp,.example.com`. | `None` | + +### `TlsConfig` — TLS / SSL (optional) + +All defaults are the most secure stance (validate the system trust +store, require a valid chain, verify hostnames). Every non-default field +is a *relaxation* — use for dev / on-prem boxes, never against +production. + +| Field | Description | Default | +|-------|-------------|---------| +| `custom_ca_cert` | PEM-encoded CA cert bytes added to the trust store on top of system roots (TLS-inspecting proxies, internal CAs). Multi-cert bundles supported. | `None` | +| `accept_self_signed` | Accept self-signed / untrusted / expired certs. **Disables all chain validation** — dev only. | `false` | +| `skip_hostname_verification` | Skip only the cert-hostname-vs-SNI check while still validating the chain (e.g. connecting via an IP literal). | `false` | +| `client_cert_pem` | PEM-encoded client certificate for mutual TLS (mTLS). Must be set together with the key. | `None` | +| `client_key_pem` | PEM-encoded private key for the mTLS client cert. Supply PKCS#8 for portability across TLS backends. Must be set together with the cert. | `None` | + +Setting only one of `client_cert_pem` / `client_key_pem` is rejected at +`Session::open` with `InvalidArgument`. + +### `ResultConfig` — result handling (optional) + +| Field | Description | Default | +|-------|-------------|---------| +| `cloudfetch_enabled` | Opt into CloudFetch (cloud-storage-backed download of large results via presigned URLs). Set `false` to force the inline-Arrow path (mirrors JDBC `EnableQueryResultDownload=0`). | `true` | +| `cloudfetch_link_prefetch_window` | Number of presigned URLs to prefetch ahead of the consumer. | `10` | +| `cloudfetch_max_chunks_in_memory` | Max decompressed CloudFetch chunks held in memory at once (bounds download parallelism and peak RSS). | `16` | +| `inline_max_chunks_in_memory` | Prefetch window for the inline-Arrow path (used when CloudFetch is disabled). `1` disables prefetching. | `4` | +| `complex_types_as_json` | Render complex columns (`ARRAY` / `MAP` / `STRUCT` / `VARIANT` / `GEOMETRY` / `GEOGRAPHY`) as compact JSON strings instead of native Arrow nested types. | `false` | +| `intervals_as_string` | Render `INTERVAL` / `DURATION` columns as canonical Databricks text (e.g. `"Y-M"`, `"D HH:MM:SS.nnnnnnnnn"`) instead of native Arrow interval types. | `false` | + +### `LoggingConfig` — logging (optional) + +| Field | Description | Default | +|-------|-------------|---------| +| `filter` | Log filter, e.g. `databricks_sql_kernel=debug`. When `None`, the kernel honours the `RUST_LOG` env var. | `None` (uses `RUST_LOG`) | +| `file` | File to write logs to. When `None`, logs go to stderr. | `None` (stderr) | + +### `transport` — wire protocol (optional) + +`Option`. v0 supports `SeaRest` (Statement Execution API +over REST) only; the enum is reserved to grow `SeaGrpc` / `Thrift` in +v1+. `None` lets the kernel pick the default. + +Default: `SeaRest`. + +### `session_conf` — server-side session configuration (optional) + +`session_conf: HashMap` carries **server-bound** SQL / +Spark configuration, forwarded to SEA `session_confs` and applied for +every statement on the session. Keys are matched **case-insensitively** +against an allowlist and **uppercased** before being sent; keys not in +the allowlist are **dropped with a warning**. + +Allowlisted keys (see the [Databricks SQL configuration-parameters +reference](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-parameters) +for per-parameter meaning and accepted values): + +| Key | Notes | +|-----|-------| +| `ANSI_MODE` | Enable/disable ANSI SQL behaviour. | +| `CAN_CLOUD_DOWNLOAD` | Kernel-synthesised from `ResultConfig::cloudfetch_enabled = false`; a user-supplied value (any casing) wins. | +| `COLLATION` | Default collation. | +| `ENABLE_PHOTON` | Toggle the Photon engine. | +| `LEGACY_TIME_PARSER_POLICY` | Legacy datetime parsing behaviour. | +| `MAX_FILE_PARTITION_BYTES` | Max bytes per file partition. | +| `QUERY_TAGS` | Query tags (comma-separated `key:value`). | +| `READ_ONLY_EXTERNAL_METASTORE` | Treat the external metastore as read-only. | +| `STATEMENT_TIMEOUT` | Server-side per-statement timeout (seconds). This is the real query-timeout knob. | +| `TIMEZONE` | Session time zone, e.g. `UTC`. | +| `USE_CACHED_RESULT` | Toggle result caching. | + +Dotted `spark.*` confs are matched case-insensitively but sent +**verbatim** (Spark conf keys are case-sensitive): + +| Key | Notes | +|-----|-------| +| `spark.sql.thriftserver.metadata.metricview.enabled` | When `"true"`, `SHOW TABLES` returns `METRIC_VIEW` rows and `getColumns` surfaces `measure` columns. Mirrors JDBC `EnableMetricViewMetadata` (default off). | + +Boolean-valued keys should use the exact strings `"true"` / `"false"`; +the kernel does not pre-validate values and forwards them as-is. ## License diff --git a/docs/connection-parameters.md b/docs/connection-parameters.md deleted file mode 100644 index fcd73765..00000000 --- a/docs/connection-parameters.md +++ /dev/null @@ -1,335 +0,0 @@ - - -# Connection Parameters - -Every configuration knob the Databricks SQL Kernel accepts, grouped by -concern, with its meaning and default value. - -The kernel is consumed through three surfaces, and each names the same -underlying knob slightly differently: - -| Surface | How parameters are supplied | -|---------|-----------------------------| -| **Rust** (`databricks-sql-kernel`) | Typed config structs on `SessionConfig` — one sub-struct per concern (`ConnectionConfig`, `AuthConfig`, `HttpConfig`, `TlsConfig`, `ProxyConfig`, `ResultConfig`, `DefaultOpts`, `LoggingConfig`), assembled and passed to `Session::open`. | -| **Python** (`databricks-sql-kernel` wheel) | Keyword arguments to `Session(host, http_path, **kwargs)`. | -| **Node.js** (`@databricks/databricks-sql-kernel`) | Fields on the `ConnectionOptions` object passed to `openSession(options)`. | - -Each table below lists the **Rust field**, the **Python kwarg**, and the -**Node.js option** for the same parameter, so wrapper authors and driver -users can cross-reference. A blank cell means that binding does not -expose the knob yet (the Rust core always does). - -> **Note on defaults.** The "Default" column is the kernel-core default -> from `src/config.rs`. Some bindings apply a binding-specific default -> that differs — those are called out in the notes under each table. - ---- - -## Table of contents - -- [Connection identity](#connection-identity) — host, warehouse, org -- [Authentication](#authentication) — PAT, OAuth M2M, OAuth U2M -- [Session defaults](#session-defaults) — catalog, schema, transactions -- [HTTP client](#http-client) — timeouts, pool size, retries, headers -- [Proxy](#proxy) -- [TLS / SSL](#tls--ssl) -- [Result handling](#result-handling) — CloudFetch, type rendering -- [Logging](#logging) -- [Server-side session configuration](#server-side-session-configuration) — `session_conf` -- [Transport](#transport) - ---- - -## Connection identity - -Required. Identifies the workspace and warehouse to connect to. - -| Rust (`ConnectionConfig`) | Python kwarg | Node.js (`ConnectionOptions`) | Description | Default | -|---|---|---|---|---| -| `host` | `host` | `hostName` | Workspace URL, e.g. `https://my-workspace.databricks.com`. Bare hostnames get `https://` prepended and any trailing `/` stripped. | **(required)** | -| `warehouse_id` | (parsed from `http_path`) | (parsed from `httpPath`) | Warehouse id, e.g. `abc123`. In Rust use `ConnectionConfig::from_http_path` to parse it out of a `/sql/1.0/warehouses/{id}` path; the bindings accept the full HTTP path directly. | **(required)** | -| `org_id` | (parsed from `http_path`) | (parsed from `httpPath`) | Workspace organization id for multi-tenant routing. Sent as the `x-databricks-org-id` header. Auto-populated from the `?o=` query parameter of the HTTP path. | `None` | - -**Notes** - -- Accepted HTTP-path forms: `/sql/1.0/warehouses/{id}` (canonical) and - `/sql/1.0/endpoints/{id}` (legacy, equivalent server-side), with or - without a leading `/`, and with an optional `?o={org_id}` suffix. -- Python / Node.js take `http_path` / `httpPath` and the kernel parses - the warehouse id and org id out of it. - ---- - -## Authentication - -Required. The kernel supports a personal access token and two OAuth 2.0 -flows. Select the flow with `auth_type` (Python) / `authMode` (Node.js), -or by choosing the `AuthConfig` variant (Rust). Omitting the selector -defaults to **PAT** when a token is supplied. - -### Personal access token (PAT) - -| Rust (`AuthConfig::Pat`) | Python kwarg | Node.js | Description | Default | -|---|---|---|---|---| -| `token` | `access_token` | `token` | Personal access token (`dapi…`). Must be non-empty. | **(required for PAT)** | - -### OAuth 2.0 machine-to-machine (M2M, client credentials) - -Service-principal auth. Select with `auth_type="oauth-m2m"` / `authMode: OAuthM2m`. - -| Rust (`AuthConfig::OAuthM2M`) | Python kwarg | Node.js | Description | Default | -|---|---|---|---|---| -| `client_id` | `client_id` | `oauthClientId` | OAuth client id. Must be non-empty. | **(required for M2M)** | -| `client_secret` | `client_secret` | `oauthClientSecret` | OAuth client secret. Must be non-empty. | **(required for M2M)** | -| `scopes` | `oauth_scopes` | `oauthScopes` | OAuth scopes to request. | `["all-apis"]` | -| `token_url_override` | `token_url` | | Token endpoint override. | OIDC discovery at `/.well-known/oauth-authorization-server` | - -### OAuth 2.0 user-to-machine (U2M, browser flow) - -Authorization code + PKCE. The kernel opens the user's browser and runs a -localhost listener for the callback. Select with `auth_type="oauth-u2m"` / -`authMode: OAuthU2m`. - -| Rust (`AuthConfig::OAuthU2M`) | Python kwarg | Node.js | Description | Default | -|---|---|---|---|---| -| `client_id` | `client_id` | `oauthClientId` | OAuth client id. | `"databricks-cli"` | -| `redirect_port` | `redirect_port` | `oauthRedirectPort` | Localhost port for the OAuth callback listener. | `8020` | -| `scopes` | `oauth_scopes` | `oauthScopes` | OAuth scopes. `offline_access` is needed for a refresh token (cached and refreshed transparently). | `["all-apis", "offline_access"]` | -| `token_url_override` | `token_url` | | Token endpoint override. | OIDC discovery | -| `callback_timeout` | `oauth_callback_timeout_secs` | | How long to wait for the user to complete the browser flow. | `120s` | - -**Notes** - -- Two further Rust variants exist but are **not** exposed by the bindings: - `AuthConfig::OAuthFederation` (RFC 8693 token exchange — reserved, - returns `InvalidArgument` until implemented) and `AuthConfig::External` - (a caller-supplied `TokenProvider` trait, a Rust-only escape hatch). -- The Node.js binding defaults the U2M client id to - `databricks-sql-connector` (rather than the core's `databricks-cli`). - ---- - -## Session defaults - -Optional. Per-session defaults applied to every statement. - -| Rust (`DefaultOpts`) | Python kwarg | Node.js | Description | Default | -|---|---|---|---|---| -| `catalog` | `catalog` | `catalog` | Default catalog for statements on this session (SEA `CreateSession.catalog`). | `None` (server default) | -| `schema` | `schema` | `schema` | Default schema for statements on this session (SEA `CreateSession.schema`). | `None` (server default) | -| `ignore_transactions` | | | When `true`, transaction-control calls (`set_autocommit(false)`, `commit()`, `rollback()`) are silently no-oped. Mirrors JDBC `IgnoreTransactions=1`. Set `false` to opt into real multi-statement transactions (Private Preview; requires catalog-managed tables). | `true` | - ---- - -## HTTP client - -Optional. Tunes timeouts, the connection pool, retry/backoff, and custom -headers. - -| Rust (`HttpConfig`) | Python kwarg | Node.js | Description | Default | -|---|---|---|---|---| -| `request_timeout` | | `socketTimeoutMs` | Per-request timeout (connect + body) — caps a single HTTP round-trip. | `120s` | -| `overall_timeout` | `retry_overall_timeout_secs` | `retryOverallTimeoutSecs` | Maximum total time across retries for one logical RPC. | `900s` | -| `pool_max_idle_per_host` | | `maxConnections` | Connection-pool size (max idle warm sockets per host). Raise for bursty concurrent workloads. | `100` | -| `retry_min_wait` | `retry_min_wait_secs` | `retryMinWaitSecs` | Minimum backoff between retries; also the floor for a server `Retry-After` and the base of exponential backoff (`min_wait × 2^attempt`). | `1s` | -| `retry_max_wait` | `retry_max_wait_secs` | `retryMaxWaitSecs` | Maximum backoff between retries; caps both the exponential backoff and a server `Retry-After`. | `60s` | -| `retry_max_retries` | `retry_max_attempts` | `retryMaxAttempts` | See note below on retries-vs-attempts. | `5` retries (`6` total attempts) | -| `custom_headers` | `http_headers` | `customHeaders` | Extra headers on every request. Ordered list of `(name, value)`; duplicates allowed. | `[]` (none) | - -**Notes** - -- **Retries vs. attempts.** The Rust `retry_max_retries` counts retries - *after* the first attempt (so `5` → 6 total attempts). The Python - `retry_max_attempts` and Node.js `retryMaxAttempts` are **total - attempts** (matching the connector's `_retry_stop_after_attempts_count` - and JDBC), converted internally as `retry_max_retries = max(0, attempts − 1)`. - Passing `0` or `1` both mean "one attempt, no retries". -- **Reserved headers.** `Authorization` and `x-databricks-org-id` in - `custom_headers` are silently dropped (with a warning) so auth and - multi-tenant routing can't be hijacked. A caller `User-Agent` is folded - into the effective UA rather than sent as a duplicate. -- The Node.js binding applies a binding-specific `maxConnections` default - of `100` when unset (matches the core). - ---- - -## Proxy - -Optional. Programmatic HTTP/HTTPS proxy. When unset, the kernel does not -configure a proxy and `reqwest`'s standard `HTTP_PROXY` / `HTTPS_PROXY` / -`NO_PROXY` environment-variable behaviour applies. Setting `url` -**overrides** those env vars. - -| Rust (`ProxyConfig`) | Python kwarg | Node.js (`ProxyInput`) | Description | Default | -|---|---|---|---|---| -| `url` | | `proxy.url` | Proxy endpoint, e.g. `http://proxy.corp.example.com:8080`. Must be `http://` or `https://`. | `None` (env-var behaviour) | -| `username` | | `proxy.username` | Proxy basic-auth username. Overrides credentials embedded in `url`. | `None` | -| `password` | | `proxy.password` | Proxy basic-auth password. Ignored unless `username` is set. Redacted in logs. | `None` | -| `bypass_hosts` | | `proxy.bypassHosts` | Comma-separated hosts/domains to bypass the proxy, e.g. `localhost,*.internal.corp,.example.com`. | `None` | - -**Notes** - -- The Python binding does not currently expose a programmatic proxy; - Python users rely on the `HTTP(S)_PROXY` environment variables. - ---- - -## TLS / SSL - -Optional. **All defaults are the most secure stance:** validate the -system trust store, require a valid chain, and verify hostnames. Every -non-default field is a *relaxation* — use for dev / on-prem boxes, never -against production. - -| Rust (`TlsConfig`) | Python kwarg | Node.js | Description | Default | -|---|---|---|---|---| -| `custom_ca_cert` | `tls_ca_cert` | `customCaCert` | PEM-encoded CA cert bytes added to the trust store on top of system roots (for TLS-inspecting proxies or internal CAs). Multi-cert bundles (root + intermediate) are supported. | `None` | -| `accept_self_signed` | `tls_skip_verify` | `checkServerCertificate` (inverted) | Accept self-signed / untrusted / expired certs. **Disables all chain validation** — dev only. | `false` (validation on) | -| `skip_hostname_verification` | `tls_skip_hostname_verify` | `checkServerCertificateHostname` (inverted) | Skip only the cert-hostname-vs-SNI check while still validating the chain (e.g. connecting via an IP literal). | `false` (check on) | -| `client_cert_pem` | `tls_client_cert` | `clientCertPem` | PEM-encoded client certificate for mutual TLS (mTLS). Must be set together with the key. | `None` | -| `client_key_pem` | `tls_client_key` | `clientKeyPem` | PEM-encoded private key for the mTLS client cert. Supply PKCS#8 for portability across TLS backends. Must be set together with the cert. | `None` | - -**Notes** - -- The Node.js knobs are **positive** booleans: `checkServerCertificate` - (default `true`) is the master verify toggle — setting it `false` - disables chain validation *and* subsumes the hostname check; - `checkServerCertificateHostname` (default `true`) toggles only the - hostname check. These map to the inverse of the Rust - `accept_self_signed` / `skip_hostname_verification` fields. -- Setting only one of `client_cert_pem` / `client_key_pem` is rejected at - `Session::open` with `InvalidArgument`. - ---- - -## Result handling - -Optional. Tunes CloudFetch and how result columns are rendered. - -| Rust (`ResultConfig`) | Python kwarg | Node.js | Description | Default | -|---|---|---|---|---| -| `cloudfetch_enabled` | | | Opt into CloudFetch (cloud-storage-backed download of large results via presigned URLs). Set `false` to force the inline-Arrow path (mirrors JDBC `EnableQueryResultDownload=0`). | `true` | -| `cloudfetch_link_prefetch_window` | | | Number of presigned URLs to prefetch ahead of the consumer. | `10` | -| `cloudfetch_max_chunks_in_memory` | | | Max decompressed CloudFetch chunks held in memory at once (bounds download parallelism and peak RSS). | `16` | -| `inline_max_chunks_in_memory` | | | Prefetch window for the inline-Arrow path (used when CloudFetch is disabled). `1` disables prefetching (strict lazy fetch). | `4` | -| `complex_types_as_json` | `complex_types_as_json` | `complexTypesAsJson` | Render complex columns (`ARRAY` / `MAP` / `STRUCT` / `VARIANT` / `GEOMETRY` / `GEOGRAPHY`) as compact JSON strings instead of native Arrow nested types. | `false` | -| `intervals_as_string` | `intervals_as_string` | `intervalsAsString` | Render `INTERVAL` / `DURATION` columns as canonical Databricks text (e.g. `"Y-M"`, `"D HH:MM:SS.nnnnnnnnn"`) instead of native Arrow interval types. Needed for pyarrow consumers, which can't decode Arrow `month_interval`. | `false` | - -**Notes** - -- The CloudFetch tuning knobs are Rust-core only today; the bindings - expose the two result-rendering toggles (`complex_types_as_json`, - `intervals_as_string`) but inherit the CloudFetch defaults. - ---- - -## Logging - -Optional. Rust-core only — bindings install their own log bridges (the -Node.js binding via `initKernelLogging`, the Python binding via its -`logging` module). - -| Rust (`LoggingConfig`) | Description | Default | -|---|---|---| -| `filter` | Log filter, e.g. `databricks_sql_kernel=debug`. When `None`, the kernel honours the `RUST_LOG` environment variable. | `None` (uses `RUST_LOG`) | -| `file` | File to write logs to. When `None`, logs go to stderr. | `None` (stderr) | - ---- - -## Server-side session configuration - -The `session_conf` (Rust / Python) / `sessionConf` (Node.js) map carries -**server-bound** SQL / Spark configuration, forwarded to SEA -`session_confs` and applied for every statement on the session. - -| Rust / Python | Node.js | Description | Default | -|---|---|---|---| -| `session_conf` | `sessionConf` | Map of server-side session-config key → value. | `{}` (empty) | - -Keys are matched **case-insensitively** against a kernel allowlist and -**uppercased** before being sent (the server echoes them uppercase, so -`SET`-readback matches). Keys not in the allowlist are **dropped with a -warning**. - -### Allowed keys - -Sourced from the [Databricks SQL configuration-parameters -reference](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-parameters) -plus the additional keys the Java driver accepts. See that page for the -per-parameter meaning and accepted values. - -| Key | Notes | -|---|---| -| `ANSI_MODE` | Enable/disable ANSI SQL behaviour. | -| `CAN_CLOUD_DOWNLOAD` | Kernel-synthesised from `ResultConfig::cloudfetch_enabled = false`; a user-supplied value (any casing) wins. | -| `COLLATION` | Default collation. | -| `ENABLE_PHOTON` | Toggle the Photon engine. | -| `LEGACY_TIME_PARSER_POLICY` | Legacy datetime parsing behaviour. | -| `MAX_FILE_PARTITION_BYTES` | Max bytes per file partition. | -| `QUERY_TAGS` | Query tags (comma-separated `key:value`). | -| `READ_ONLY_EXTERNAL_METASTORE` | Treat the external metastore as read-only. | -| `STATEMENT_TIMEOUT` | Server-side per-statement timeout (seconds). This is the real query-timeout knob. | -| `TIMEZONE` | Session time zone, e.g. `UTC`. | -| `USE_CACHED_RESULT` | Toggle result caching. | - -### Case-sensitive Spark confs - -Dotted `spark.*` confs are matched case-insensitively but sent -**verbatim** (Spark conf keys are case-sensitive and must not be -uppercased): - -| Key | Notes | -|---|---| -| `spark.sql.thriftserver.metadata.metricview.enabled` | When `"true"`, `SHOW TABLES` returns `METRIC_VIEW` rows and `getColumns` surfaces `measure` columns. Mirrors JDBC `EnableMetricViewMetadata` (default off). | - -**Notes** - -- Boolean-valued keys should use the exact strings `"true"` / `"false"`; - other forms (`"True"`, `"yes"`, `"1"`) are undefined server-side. The - kernel does not pre-validate values — it trusts the supplied - `session_conf` and forwards values as-is. - ---- - -## Transport - -Optional. Wire-protocol selection. Rust-core only. - -| Rust (`TransportMode`) | Description | Default | -|---|---|---| -| `transport` | Wire protocol. v0 supports `SeaRest` (Statement Execution API over REST) only; the enum is reserved to grow `SeaGrpc` / `Thrift` in v1+. | `SeaRest` | - ---- - -## Per-statement options - -The parameters above are **session-level**. A few knobs are set -per-statement rather than per-session (via `StatementSpec` in Rust and -`ExecuteOptions` in the Node.js binding): - -- `statement_conf` / `statementConf` — per-statement Spark-conf overlay, - merged on top of the session `session_conf` (statement wins on key - collisions). -- `query_tags` / `queryTags` — convenience over `statement_conf`'s - `query_tags` key. -- `row_limit` / `rowLimit` — server-side cap on rows returned (SEA - `row_limit`), independent of any SQL `LIMIT`. -- Bound parameters — positional (`?`) and named (`:name`) query - parameters. - -See `docs/spec-v0.md` and the `StatementSpec` docs for the full -per-statement surface. From 76208b0d229c851db97c41b093d68eb5dd6ef86f Mon Sep 17 00:00:00 2001 From: eric-wang-1990 Date: Wed, 22 Jul 2026 00:59:37 -0700 Subject: [PATCH 03/12] docs: document client-only session_conf keys Add the cloudfetch_max_chunks_in_memory client-only session_conf key (read at session-create, folded into ResultConfig, stripped before the wire; default 16, clamped to 256) and clarify that LZ4 compression is auto-detected from the result manifest rather than a user parameter. Co-authored-by: Isaac Signed-off-by: eric-wang-1990 --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 900ea8b9..2a9070ac 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,23 @@ Dotted `spark.*` confs are matched case-insensitively but sent Boolean-valued keys should use the exact strings `"true"` / `"false"`; the kernel does not pre-validate values and forwards them as-is. +#### Client-only `session_conf` keys + +Some keys carried in the same `session_conf` map are **client-side** +tuning knobs: the kernel reads them at session creation, applies them to +the typed config above, and then strips them so they never reach the SEA +wire (they are deliberately *not* in the allowlist). They exist so C ABI +(Go / ODBC) consumers can set them through the existing +`session_conf` entry point without a dedicated symbol. + +| Key | Description | Default | +|-----|-------------|---------| +| `cloudfetch_max_chunks_in_memory` | Same knob as `ResultConfig::cloudfetch_max_chunks_in_memory` — max decompressed CloudFetch chunks held in memory at once. Matched case-insensitively; parse failures / `0` are ignored (default kept), and values above `256` are clamped (peak RSS scales with this, so the ceiling bounds OOM risk). | `16` | + +Compression (LZ4) is **not** a parameter: the kernel detects it from the +server's result manifest (`result_compression`) and decompresses +`LZ4_FRAME` payloads automatically. + ## License Apache 2.0. See [LICENSE](LICENSE) and [NOTICE.txt](NOTICE.txt). From 468e333ff96f9dfac29ffdb6c55f33a2051deb33 Mon Sep 17 00:00:00 2001 From: eric-wang-1990 Date: Wed, 22 Jul 2026 01:11:08 -0700 Subject: [PATCH 04/12] docs: add quick-start example and config index to README MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Configuration section jumped straight into parameter tables with no on-ramp. Add: - a Quick start showing SessionBuilder → execute → drain → close, using the crate-root API (verified against tests/v0_execute_e2e.rs), and - a compact config-group index table linking each subsection. Content of the parameter tables is unchanged. Co-authored-by: Isaac Signed-off-by: eric-wang-1990 --- README.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2a9070ac..27ae58ff 100644 --- a/README.md +++ b/README.md @@ -37,15 +37,61 @@ cargo test make check # fmt + clippy + tests ``` +## Quick start + +Open a session with the `SessionBuilder`, then run a statement: + +```rust +use databricks_sql_kernel::{Session, AuthConfig, HttpConfig}; + +# async fn run() -> Result<(), Box> { +let session = Session::builder() + .http_path("my-workspace.databricks.com", "/sql/1.0/warehouses/abc123") + .auth(AuthConfig::pat(Some(std::env::var("DATABRICKS_TOKEN")?))?) + // optional config groups — omit to accept the defaults below: + .http(HttpConfig { pool_max_idle_per_host: 200, ..Default::default() }) + .open() + .await?; + +let mut stmt = session.statement(); +stmt.spec().sql("SELECT 1 AS n"); +let mut exec = stmt.execute().await?; + +let stream = exec.result_stream_mut(); +while let Some(_batch) = stream.next_batch().await? { /* consume rows */ } + +exec.close().await?; +session.close().await?; +# Ok(()) +# } +``` + +Each builder setter takes one config group. `.http_path(host, path)` is +shorthand for a `ConnectionConfig`; `.connection(...)`, `.auth(...)`, +`.defaults(...)`, `.http(...)`, `.proxy(...)`, `.tls(...)`, +`.result(...)`, `.logging(...)`, `.session_conf(...)`, and +`.transport(...)` set the rest. + ## Configuration A session is configured with a `SessionConfig`, assembled from typed sub-structs (one per concern) and passed to `Session::open`. Every parameter, its meaning, and its default value is listed below, grouped -by the struct it lives on. - -`ConnectionConfig` and `AuthConfig` are **required**; the rest are -optional and fall back to the defaults shown. +by the struct it lives on. `ConnectionConfig` and `AuthConfig` are +**required**; the rest are optional and fall back to the defaults shown. + +| Group | Covers | +|-------|--------| +| [`ConnectionConfig`](#connectionconfig--connection-identity-required) | host, warehouse, org id *(required)* | +| [`AuthConfig`](#authconfig--authentication-required) | PAT / OAuth M2M / OAuth U2M *(required)* | +| [`DefaultOpts`](#defaultopts--session-defaults-optional) | default catalog / schema, transactions | +| [`HttpConfig`](#httpconfig--http-client-optional) | timeouts, connection pool, retries, headers | +| [`ProxyConfig`](#proxyconfig--httphttps-proxy-optional) | HTTP/HTTPS proxy | +| [`TlsConfig`](#tlsconfig--tls--ssl-optional) | cert validation, custom CA, mTLS | +| [`ResultConfig`](#resultconfig--result-handling-optional) | CloudFetch tuning, type rendering | +| [`LoggingConfig`](#loggingconfig--logging-optional) | log filter / file | +| [`transport`](#transport--wire-protocol-optional) | wire protocol | +| [`session_conf`](#session_conf--server-side-session-configuration-optional) | server-side SQL / Spark config | ### `ConnectionConfig` — connection identity (required) From 4325652c0e7a85804dd8cc40b0daee58c788741e Mon Sep 17 00:00:00 2001 From: "peco-engineer-bot[bot]" Date: Thu, 23 Jul 2026 01:49:55 +0000 Subject: [PATCH 05/12] ai: apply changes for #184 (2 review threads) Addresses: - #3628633971 at README.md:52 - #3628633979 at README.md:47 Signed-off-by: peco-engineer-bot[bot] --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 27ae58ff..9b83577d 100644 --- a/README.md +++ b/README.md @@ -44,12 +44,17 @@ Open a session with the `SessionBuilder`, then run a statement: ```rust use databricks_sql_kernel::{Session, AuthConfig, HttpConfig}; -# async fn run() -> Result<(), Box> { +async fn run() -> Result<(), Box> { +// `HttpConfig` is `#[non_exhaustive]` — construct from the default and +// assign the public fields you want to override: +let mut http = HttpConfig::default(); +http.pool_max_idle_per_host = 200; + let session = Session::builder() .http_path("my-workspace.databricks.com", "/sql/1.0/warehouses/abc123") .auth(AuthConfig::pat(Some(std::env::var("DATABRICKS_TOKEN")?))?) // optional config groups — omit to accept the defaults below: - .http(HttpConfig { pool_max_idle_per_host: 200, ..Default::default() }) + .http(http) .open() .await?; @@ -62,8 +67,8 @@ while let Some(_batch) = stream.next_batch().await? { /* consume rows */ } exec.close().await?; session.close().await?; -# Ok(()) -# } + Ok(()) +} ``` Each builder setter takes one config group. `.http_path(host, path)` is From 589fe245758f4e7d860ed6b6247ad58e0f33a5e7 Mon Sep 17 00:00:00 2001 From: "peco-engineer-bot[bot]" Date: Thu, 23 Jul 2026 01:56:21 +0000 Subject: [PATCH 06/12] ai: apply changes for #184 (1 review thread) Addresses: - #3635070732 at README.md:45 Signed-off-by: peco-engineer-bot[bot] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b83577d..4c049009 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ make check # fmt + clippy + tests Open a session with the `SessionBuilder`, then run a statement: ```rust -use databricks_sql_kernel::{Session, AuthConfig, HttpConfig}; +use databricks_sql_kernel::{Session, AuthConfig, HttpConfig, ExecutedStatementHandle}; async fn run() -> Result<(), Box> { // `HttpConfig` is `#[non_exhaustive]` — construct from the default and From 798860e7cbe975bf582477665ae19601205ca445 Mon Sep 17 00:00:00 2001 From: eric-wang-1990 Date: Mon, 17 Aug 2026 18:43:51 -0700 Subject: [PATCH 07/12] docs: move connection parameter reference to CONNECTION_PARAMETERS.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Match databricks-sql-nodejs#457: keep the README lean (Quick start stays) and move the full parameter reference — all config groups, defaults, and the session_conf allowlist — into a top-level CONNECTION_PARAMETERS.md, linked from the README Configuration section. Co-authored-by: Isaac Signed-off-by: eric-wang-1990 --- CONNECTION_PARAMETERS.md | 196 ++++++++++++++++++++++++++++++++++++++ README.md | 199 +-------------------------------------- 2 files changed, 201 insertions(+), 194 deletions(-) create mode 100644 CONNECTION_PARAMETERS.md diff --git a/CONNECTION_PARAMETERS.md b/CONNECTION_PARAMETERS.md new file mode 100644 index 00000000..89376493 --- /dev/null +++ b/CONNECTION_PARAMETERS.md @@ -0,0 +1,196 @@ +# Connection parameter reference + +A session is configured with a `SessionConfig`, assembled from typed +sub-structs (one per concern) and passed to `Session::open`. Every +parameter, its meaning, and its default value is listed below, grouped +by the struct it lives on. `ConnectionConfig` and `AuthConfig` are +**required**; the rest are optional and fall back to the defaults shown. + +| Group | Covers | +|-------|--------| +| [`ConnectionConfig`](#connectionconfig--connection-identity-required) | host, warehouse, org id *(required)* | +| [`AuthConfig`](#authconfig--authentication-required) | PAT / OAuth M2M / OAuth U2M *(required)* | +| [`DefaultOpts`](#defaultopts--session-defaults-optional) | default catalog / schema, transactions | +| [`HttpConfig`](#httpconfig--http-client-optional) | timeouts, connection pool, retries, headers | +| [`ProxyConfig`](#proxyconfig--httphttps-proxy-optional) | HTTP/HTTPS proxy | +| [`TlsConfig`](#tlsconfig--tls--ssl-optional) | cert validation, custom CA, mTLS | +| [`ResultConfig`](#resultconfig--result-handling-optional) | CloudFetch tuning, type rendering | +| [`LoggingConfig`](#loggingconfig--logging-optional) | log filter / file | +| [`transport`](#transport--wire-protocol-optional) | wire protocol | +| [`session_conf`](#session_conf--server-side-session-configuration-optional) | server-side SQL / Spark config | + +## `ConnectionConfig` — connection identity (required) + +Construct via `ConnectionConfig::new(host, warehouse_id)` or +`ConnectionConfig::from_http_path(host, http_path)` (which parses the +warehouse id and org id out of a `/sql/1.0/warehouses/{id}` path). + +| Field | Description | Default | +|-------|-------------|---------| +| `host` | Workspace URL, e.g. `https://my-workspace.databricks.com`. Bare hostnames get `https://` prepended and any trailing `/` stripped. | **(required)** | +| `warehouse_id` | Warehouse id, e.g. `abc123`. Accepts `/sql/1.0/warehouses/{id}` and legacy `/sql/1.0/endpoints/{id}` forms via `from_http_path`. | **(required)** | +| `org_id` | Workspace organization id for multi-tenant routing; sent as the `x-databricks-org-id` header. Auto-populated from the `?o=` query parameter of the HTTP path. | `None` | + +## `AuthConfig` — authentication (required) + +An enum; pick one variant. Use the validating constructors +(`AuthConfig::pat`, `::oauth_m2m`, `::oauth_u2m`). + +**`Pat`** — personal access token: + +| Field | Description | Default | +|-------|-------------|---------| +| `token` | Personal access token (`dapi…`). Must be non-empty. | **(required)** | + +**`OAuthM2M`** — machine-to-machine (client credentials, service principal): + +| Field | Description | Default | +|-------|-------------|---------| +| `client_id` | OAuth client id. Must be non-empty. | **(required)** | +| `client_secret` | OAuth client secret. Must be non-empty. | **(required)** | +| `scopes` | OAuth scopes to request. | `["all-apis"]` | +| `token_url_override` | Token endpoint override. | OIDC discovery at `/.well-known/oauth-authorization-server` | + +**`OAuthU2M`** — user-to-machine (authorization code + PKCE, browser flow): + +| Field | Description | Default | +|-------|-------------|---------| +| `client_id` | OAuth client id. | `"databricks-cli"` | +| `redirect_port` | Localhost port for the OAuth callback listener. | `8020` | +| `scopes` | OAuth scopes. `offline_access` is required to receive a refresh token (cached and refreshed transparently). | `["all-apis", "offline_access"]` | +| `token_url_override` | Token endpoint override. | OIDC discovery | +| `callback_timeout` | How long to wait for the user to complete the browser flow. | `120s` | + +Two further variants are reserved but not usable in v0: +`OAuthFederation` (RFC 8693 token exchange — returns `InvalidArgument` +until implemented) and `External` (a caller-supplied `TokenProvider`). + +## `DefaultOpts` — session defaults (optional) + +| Field | Description | Default | +|-------|-------------|---------| +| `catalog` | Default catalog for statements on this session. | `None` (server default) | +| `schema` | Default schema for statements on this session. | `None` (server default) | +| `ignore_transactions` | When `true`, transaction-control calls (`set_autocommit(false)`, `commit()`, `rollback()`) are silently no-oped. Mirrors JDBC `IgnoreTransactions=1`. Set `false` to opt into real multi-statement transactions (Private Preview; requires catalog-managed tables). | `true` | + +## `HttpConfig` — HTTP client (optional) + +| Field | Description | Default | +|-------|-------------|---------| +| `request_timeout` | Per-request timeout (connect + body). | `120s` | +| `overall_timeout` | Maximum total time across retries for one logical RPC. | `900s` | +| `pool_max_idle_per_host` | Connection-pool size (max idle warm sockets per host). Raise for bursty concurrent workloads. | `100` | +| `retry_min_wait` | Minimum backoff between retries; also the floor for a server `Retry-After` and the base of exponential backoff (`min_wait × 2^attempt`). | `1s` | +| `retry_max_wait` | Maximum backoff between retries; caps both the exponential backoff and a server `Retry-After`. | `60s` | +| `retry_max_retries` | Max retries **after** the first attempt — a request is tried at most `retry_max_retries + 1` times. | `5` (→ 6 total attempts) | +| `custom_headers` | Extra headers on every request; an ordered `Vec<(String, String)>` (duplicates allowed). `Authorization` / `x-databricks-org-id` are silently dropped (reserved); a `User-Agent` is folded into the effective UA. | `[]` | + +## `ProxyConfig` — HTTP/HTTPS proxy (optional) + +When `url` is `None`, the kernel does not configure a proxy and +`reqwest`'s standard `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY` env-var +behaviour applies. Setting `url` **overrides** those env vars. + +| Field | Description | Default | +|-------|-------------|---------| +| `url` | Proxy endpoint, e.g. `http://proxy.corp.example.com:8080`. Must be `http://` or `https://`. | `None` (env-var behaviour) | +| `username` | Proxy basic-auth username. Overrides credentials embedded in `url`. | `None` | +| `password` | Proxy basic-auth password. Ignored unless `username` is set. Redacted in `Debug`. | `None` | +| `bypass_hosts` | Comma-separated hosts/domains to bypass the proxy, e.g. `localhost,*.internal.corp,.example.com`. | `None` | + +## `TlsConfig` — TLS / SSL (optional) + +All defaults are the most secure stance (validate the system trust +store, require a valid chain, verify hostnames). Every non-default field +is a *relaxation* — use for dev / on-prem boxes, never against +production. + +| Field | Description | Default | +|-------|-------------|---------| +| `custom_ca_cert` | PEM-encoded CA cert bytes added to the trust store on top of system roots (TLS-inspecting proxies, internal CAs). Multi-cert bundles supported. | `None` | +| `accept_self_signed` | Accept self-signed / untrusted / expired certs. **Disables all chain validation** — dev only. | `false` | +| `skip_hostname_verification` | Skip only the cert-hostname-vs-SNI check while still validating the chain (e.g. connecting via an IP literal). | `false` | +| `client_cert_pem` | PEM-encoded client certificate for mutual TLS (mTLS). Must be set together with the key. | `None` | +| `client_key_pem` | PEM-encoded private key for the mTLS client cert. Supply PKCS#8 for portability across TLS backends. Must be set together with the cert. | `None` | + +Setting only one of `client_cert_pem` / `client_key_pem` is rejected at +`Session::open` with `InvalidArgument`. + +## `ResultConfig` — result handling (optional) + +| Field | Description | Default | +|-------|-------------|---------| +| `cloudfetch_enabled` | Opt into CloudFetch (cloud-storage-backed download of large results via presigned URLs). Set `false` to force the inline-Arrow path (mirrors JDBC `EnableQueryResultDownload=0`). | `true` | +| `cloudfetch_link_prefetch_window` | Number of presigned URLs to prefetch ahead of the consumer. | `10` | +| `cloudfetch_max_chunks_in_memory` | Max decompressed CloudFetch chunks held in memory at once (bounds download parallelism and peak RSS). | `16` | +| `inline_max_chunks_in_memory` | Prefetch window for the inline-Arrow path (used when CloudFetch is disabled). `1` disables prefetching. | `4` | +| `complex_types_as_json` | Render complex columns (`ARRAY` / `MAP` / `STRUCT` / `VARIANT` / `GEOMETRY` / `GEOGRAPHY`) as compact JSON strings instead of native Arrow nested types. | `false` | +| `intervals_as_string` | Render `INTERVAL` / `DURATION` columns as canonical Databricks text (e.g. `"Y-M"`, `"D HH:MM:SS.nnnnnnnnn"`) instead of native Arrow interval types. | `false` | + +## `LoggingConfig` — logging (optional) + +| Field | Description | Default | +|-------|-------------|---------| +| `filter` | Log filter, e.g. `databricks_sql_kernel=debug`. When `None`, the kernel honours the `RUST_LOG` env var. | `None` (uses `RUST_LOG`) | +| `file` | File to write logs to. When `None`, logs go to stderr. | `None` (stderr) | + +## `transport` — wire protocol (optional) + +`Option`. v0 supports `SeaRest` (Statement Execution API +over REST) only; the enum is reserved to grow `SeaGrpc` / `Thrift` in +v1+. `None` lets the kernel pick the default. + +Default: `SeaRest`. + +## `session_conf` — server-side session configuration (optional) + +`session_conf: HashMap` carries **server-bound** SQL / +Spark configuration, forwarded to SEA `session_confs` and applied for +every statement on the session. Keys are matched **case-insensitively** +against an allowlist and **uppercased** before being sent; keys not in +the allowlist are **dropped with a warning**. + +Allowlisted keys (see the [Databricks SQL configuration-parameters +reference](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-parameters) +for per-parameter meaning and accepted values): + +| Key | Notes | +|-----|-------| +| `ANSI_MODE` | Enable/disable ANSI SQL behaviour. | +| `CAN_CLOUD_DOWNLOAD` | Kernel-synthesised from `ResultConfig::cloudfetch_enabled = false`; a user-supplied value (any casing) wins. | +| `COLLATION` | Default collation. | +| `ENABLE_PHOTON` | Toggle the Photon engine. | +| `LEGACY_TIME_PARSER_POLICY` | Legacy datetime parsing behaviour. | +| `MAX_FILE_PARTITION_BYTES` | Max bytes per file partition. | +| `QUERY_TAGS` | Query tags (comma-separated `key:value`). | +| `READ_ONLY_EXTERNAL_METASTORE` | Treat the external metastore as read-only. | +| `STATEMENT_TIMEOUT` | Server-side per-statement timeout (seconds). This is the real query-timeout knob. | +| `TIMEZONE` | Session time zone, e.g. `UTC`. | +| `USE_CACHED_RESULT` | Toggle result caching. | + +Dotted `spark.*` confs are matched case-insensitively but sent +**verbatim** (Spark conf keys are case-sensitive): + +| Key | Notes | +|-----|-------| +| `spark.sql.thriftserver.metadata.metricview.enabled` | When `"true"`, `SHOW TABLES` returns `METRIC_VIEW` rows and `getColumns` surfaces `measure` columns. Mirrors JDBC `EnableMetricViewMetadata` (default off). | + +Boolean-valued keys should use the exact strings `"true"` / `"false"`; +the kernel does not pre-validate values and forwards them as-is. + +### Client-only `session_conf` keys + +Some keys carried in the same `session_conf` map are **client-side** +tuning knobs: the kernel reads them at session creation, applies them to +the typed config above, and then strips them so they never reach the SEA +wire (they are deliberately *not* in the allowlist). They exist so C ABI +(Go / ODBC) consumers can set them through the existing +`session_conf` entry point without a dedicated symbol. + +| Key | Description | Default | +|-----|-------------|---------| +| `cloudfetch_max_chunks_in_memory` | Same knob as `ResultConfig::cloudfetch_max_chunks_in_memory` — max decompressed CloudFetch chunks held in memory at once. Matched case-insensitively; parse failures / `0` are ignored (default kept), and values above `256` are clamped (peak RSS scales with this, so the ceiling bounds OOM risk). | `16` | + +Compression (LZ4) is **not** a parameter: the kernel detects it from the +server's result manifest (`result_compression`) and decompresses +`LZ4_FRAME` payloads automatically. diff --git a/README.md b/README.md index 4c049009..d4e8b3a1 100644 --- a/README.md +++ b/README.md @@ -79,200 +79,11 @@ shorthand for a `ConnectionConfig`; `.connection(...)`, `.auth(...)`, ## Configuration -A session is configured with a `SessionConfig`, assembled from typed -sub-structs (one per concern) and passed to `Session::open`. Every -parameter, its meaning, and its default value is listed below, grouped -by the struct it lives on. `ConnectionConfig` and `AuthConfig` are -**required**; the rest are optional and fall back to the defaults shown. - -| Group | Covers | -|-------|--------| -| [`ConnectionConfig`](#connectionconfig--connection-identity-required) | host, warehouse, org id *(required)* | -| [`AuthConfig`](#authconfig--authentication-required) | PAT / OAuth M2M / OAuth U2M *(required)* | -| [`DefaultOpts`](#defaultopts--session-defaults-optional) | default catalog / schema, transactions | -| [`HttpConfig`](#httpconfig--http-client-optional) | timeouts, connection pool, retries, headers | -| [`ProxyConfig`](#proxyconfig--httphttps-proxy-optional) | HTTP/HTTPS proxy | -| [`TlsConfig`](#tlsconfig--tls--ssl-optional) | cert validation, custom CA, mTLS | -| [`ResultConfig`](#resultconfig--result-handling-optional) | CloudFetch tuning, type rendering | -| [`LoggingConfig`](#loggingconfig--logging-optional) | log filter / file | -| [`transport`](#transport--wire-protocol-optional) | wire protocol | -| [`session_conf`](#session_conf--server-side-session-configuration-optional) | server-side SQL / Spark config | - -### `ConnectionConfig` — connection identity (required) - -Construct via `ConnectionConfig::new(host, warehouse_id)` or -`ConnectionConfig::from_http_path(host, http_path)` (which parses the -warehouse id and org id out of a `/sql/1.0/warehouses/{id}` path). - -| Field | Description | Default | -|-------|-------------|---------| -| `host` | Workspace URL, e.g. `https://my-workspace.databricks.com`. Bare hostnames get `https://` prepended and any trailing `/` stripped. | **(required)** | -| `warehouse_id` | Warehouse id, e.g. `abc123`. Accepts `/sql/1.0/warehouses/{id}` and legacy `/sql/1.0/endpoints/{id}` forms via `from_http_path`. | **(required)** | -| `org_id` | Workspace organization id for multi-tenant routing; sent as the `x-databricks-org-id` header. Auto-populated from the `?o=` query parameter of the HTTP path. | `None` | - -### `AuthConfig` — authentication (required) - -An enum; pick one variant. Use the validating constructors -(`AuthConfig::pat`, `::oauth_m2m`, `::oauth_u2m`). - -**`Pat`** — personal access token: - -| Field | Description | Default | -|-------|-------------|---------| -| `token` | Personal access token (`dapi…`). Must be non-empty. | **(required)** | - -**`OAuthM2M`** — machine-to-machine (client credentials, service principal): - -| Field | Description | Default | -|-------|-------------|---------| -| `client_id` | OAuth client id. Must be non-empty. | **(required)** | -| `client_secret` | OAuth client secret. Must be non-empty. | **(required)** | -| `scopes` | OAuth scopes to request. | `["all-apis"]` | -| `token_url_override` | Token endpoint override. | OIDC discovery at `/.well-known/oauth-authorization-server` | - -**`OAuthU2M`** — user-to-machine (authorization code + PKCE, browser flow): - -| Field | Description | Default | -|-------|-------------|---------| -| `client_id` | OAuth client id. | `"databricks-cli"` | -| `redirect_port` | Localhost port for the OAuth callback listener. | `8020` | -| `scopes` | OAuth scopes. `offline_access` is required to receive a refresh token (cached and refreshed transparently). | `["all-apis", "offline_access"]` | -| `token_url_override` | Token endpoint override. | OIDC discovery | -| `callback_timeout` | How long to wait for the user to complete the browser flow. | `120s` | - -Two further variants are reserved but not usable in v0: -`OAuthFederation` (RFC 8693 token exchange — returns `InvalidArgument` -until implemented) and `External` (a caller-supplied `TokenProvider`). - -### `DefaultOpts` — session defaults (optional) - -| Field | Description | Default | -|-------|-------------|---------| -| `catalog` | Default catalog for statements on this session. | `None` (server default) | -| `schema` | Default schema for statements on this session. | `None` (server default) | -| `ignore_transactions` | When `true`, transaction-control calls (`set_autocommit(false)`, `commit()`, `rollback()`) are silently no-oped. Mirrors JDBC `IgnoreTransactions=1`. Set `false` to opt into real multi-statement transactions (Private Preview; requires catalog-managed tables). | `true` | - -### `HttpConfig` — HTTP client (optional) - -| Field | Description | Default | -|-------|-------------|---------| -| `request_timeout` | Per-request timeout (connect + body). | `120s` | -| `overall_timeout` | Maximum total time across retries for one logical RPC. | `900s` | -| `pool_max_idle_per_host` | Connection-pool size (max idle warm sockets per host). Raise for bursty concurrent workloads. | `100` | -| `retry_min_wait` | Minimum backoff between retries; also the floor for a server `Retry-After` and the base of exponential backoff (`min_wait × 2^attempt`). | `1s` | -| `retry_max_wait` | Maximum backoff between retries; caps both the exponential backoff and a server `Retry-After`. | `60s` | -| `retry_max_retries` | Max retries **after** the first attempt — a request is tried at most `retry_max_retries + 1` times. | `5` (→ 6 total attempts) | -| `custom_headers` | Extra headers on every request; an ordered `Vec<(String, String)>` (duplicates allowed). `Authorization` / `x-databricks-org-id` are silently dropped (reserved); a `User-Agent` is folded into the effective UA. | `[]` | - -### `ProxyConfig` — HTTP/HTTPS proxy (optional) - -When `url` is `None`, the kernel does not configure a proxy and -`reqwest`'s standard `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY` env-var -behaviour applies. Setting `url` **overrides** those env vars. - -| Field | Description | Default | -|-------|-------------|---------| -| `url` | Proxy endpoint, e.g. `http://proxy.corp.example.com:8080`. Must be `http://` or `https://`. | `None` (env-var behaviour) | -| `username` | Proxy basic-auth username. Overrides credentials embedded in `url`. | `None` | -| `password` | Proxy basic-auth password. Ignored unless `username` is set. Redacted in `Debug`. | `None` | -| `bypass_hosts` | Comma-separated hosts/domains to bypass the proxy, e.g. `localhost,*.internal.corp,.example.com`. | `None` | - -### `TlsConfig` — TLS / SSL (optional) - -All defaults are the most secure stance (validate the system trust -store, require a valid chain, verify hostnames). Every non-default field -is a *relaxation* — use for dev / on-prem boxes, never against -production. - -| Field | Description | Default | -|-------|-------------|---------| -| `custom_ca_cert` | PEM-encoded CA cert bytes added to the trust store on top of system roots (TLS-inspecting proxies, internal CAs). Multi-cert bundles supported. | `None` | -| `accept_self_signed` | Accept self-signed / untrusted / expired certs. **Disables all chain validation** — dev only. | `false` | -| `skip_hostname_verification` | Skip only the cert-hostname-vs-SNI check while still validating the chain (e.g. connecting via an IP literal). | `false` | -| `client_cert_pem` | PEM-encoded client certificate for mutual TLS (mTLS). Must be set together with the key. | `None` | -| `client_key_pem` | PEM-encoded private key for the mTLS client cert. Supply PKCS#8 for portability across TLS backends. Must be set together with the cert. | `None` | - -Setting only one of `client_cert_pem` / `client_key_pem` is rejected at -`Session::open` with `InvalidArgument`. - -### `ResultConfig` — result handling (optional) - -| Field | Description | Default | -|-------|-------------|---------| -| `cloudfetch_enabled` | Opt into CloudFetch (cloud-storage-backed download of large results via presigned URLs). Set `false` to force the inline-Arrow path (mirrors JDBC `EnableQueryResultDownload=0`). | `true` | -| `cloudfetch_link_prefetch_window` | Number of presigned URLs to prefetch ahead of the consumer. | `10` | -| `cloudfetch_max_chunks_in_memory` | Max decompressed CloudFetch chunks held in memory at once (bounds download parallelism and peak RSS). | `16` | -| `inline_max_chunks_in_memory` | Prefetch window for the inline-Arrow path (used when CloudFetch is disabled). `1` disables prefetching. | `4` | -| `complex_types_as_json` | Render complex columns (`ARRAY` / `MAP` / `STRUCT` / `VARIANT` / `GEOMETRY` / `GEOGRAPHY`) as compact JSON strings instead of native Arrow nested types. | `false` | -| `intervals_as_string` | Render `INTERVAL` / `DURATION` columns as canonical Databricks text (e.g. `"Y-M"`, `"D HH:MM:SS.nnnnnnnnn"`) instead of native Arrow interval types. | `false` | - -### `LoggingConfig` — logging (optional) - -| Field | Description | Default | -|-------|-------------|---------| -| `filter` | Log filter, e.g. `databricks_sql_kernel=debug`. When `None`, the kernel honours the `RUST_LOG` env var. | `None` (uses `RUST_LOG`) | -| `file` | File to write logs to. When `None`, logs go to stderr. | `None` (stderr) | - -### `transport` — wire protocol (optional) - -`Option`. v0 supports `SeaRest` (Statement Execution API -over REST) only; the enum is reserved to grow `SeaGrpc` / `Thrift` in -v1+. `None` lets the kernel pick the default. - -Default: `SeaRest`. - -### `session_conf` — server-side session configuration (optional) - -`session_conf: HashMap` carries **server-bound** SQL / -Spark configuration, forwarded to SEA `session_confs` and applied for -every statement on the session. Keys are matched **case-insensitively** -against an allowlist and **uppercased** before being sent; keys not in -the allowlist are **dropped with a warning**. - -Allowlisted keys (see the [Databricks SQL configuration-parameters -reference](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-parameters) -for per-parameter meaning and accepted values): - -| Key | Notes | -|-----|-------| -| `ANSI_MODE` | Enable/disable ANSI SQL behaviour. | -| `CAN_CLOUD_DOWNLOAD` | Kernel-synthesised from `ResultConfig::cloudfetch_enabled = false`; a user-supplied value (any casing) wins. | -| `COLLATION` | Default collation. | -| `ENABLE_PHOTON` | Toggle the Photon engine. | -| `LEGACY_TIME_PARSER_POLICY` | Legacy datetime parsing behaviour. | -| `MAX_FILE_PARTITION_BYTES` | Max bytes per file partition. | -| `QUERY_TAGS` | Query tags (comma-separated `key:value`). | -| `READ_ONLY_EXTERNAL_METASTORE` | Treat the external metastore as read-only. | -| `STATEMENT_TIMEOUT` | Server-side per-statement timeout (seconds). This is the real query-timeout knob. | -| `TIMEZONE` | Session time zone, e.g. `UTC`. | -| `USE_CACHED_RESULT` | Toggle result caching. | - -Dotted `spark.*` confs are matched case-insensitively but sent -**verbatim** (Spark conf keys are case-sensitive): - -| Key | Notes | -|-----|-------| -| `spark.sql.thriftserver.metadata.metricview.enabled` | When `"true"`, `SHOW TABLES` returns `METRIC_VIEW` rows and `getColumns` surfaces `measure` columns. Mirrors JDBC `EnableMetricViewMetadata` (default off). | - -Boolean-valued keys should use the exact strings `"true"` / `"false"`; -the kernel does not pre-validate values and forwards them as-is. - -#### Client-only `session_conf` keys - -Some keys carried in the same `session_conf` map are **client-side** -tuning knobs: the kernel reads them at session creation, applies them to -the typed config above, and then strips them so they never reach the SEA -wire (they are deliberately *not* in the allowlist). They exist so C ABI -(Go / ODBC) consumers can set them through the existing -`session_conf` entry point without a dedicated symbol. - -| Key | Description | Default | -|-----|-------------|---------| -| `cloudfetch_max_chunks_in_memory` | Same knob as `ResultConfig::cloudfetch_max_chunks_in_memory` — max decompressed CloudFetch chunks held in memory at once. Matched case-insensitively; parse failures / `0` are ignored (default kept), and values above `256` are clamped (peak RSS scales with this, so the ceiling bounds OOM risk). | `16` | - -Compression (LZ4) is **not** a parameter: the kernel detects it from the -server's result manifest (`result_compression`) and decompresses -`LZ4_FRAME` payloads automatically. +A session is configured with a `SessionConfig` — typed sub-structs (one +per concern) passed to `Session::open`. `ConnectionConfig` and `AuthConfig` +are required; the rest are optional. See +[CONNECTION_PARAMETERS.md](CONNECTION_PARAMETERS.md) for every parameter — +its meaning, default value, and the struct it lives on. ## License From b363a366ef4986f11e6f0da88eeb77383b3c9159 Mon Sep 17 00:00:00 2001 From: eric-wang-1990 Date: Mon, 17 Aug 2026 18:54:14 -0700 Subject: [PATCH 08/12] docs: update U2M defaults to databricks-sql-connector app (#247) PR #247 (PECOBLR-4039) changed the default U2M OAuth app: client_id databricks-cli -> databricks-sql-connector, redirect_port 8020 -> 8030, scopes [all-apis, offline_access] -> [sql, offline_access]. The reference was copied from the pre-#247 README; sync it to current main. Co-authored-by: Isaac Signed-off-by: eric-wang-1990 --- CONNECTION_PARAMETERS.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONNECTION_PARAMETERS.md b/CONNECTION_PARAMETERS.md index 89376493..475bb26f 100644 --- a/CONNECTION_PARAMETERS.md +++ b/CONNECTION_PARAMETERS.md @@ -55,9 +55,9 @@ An enum; pick one variant. Use the validating constructors | Field | Description | Default | |-------|-------------|---------| -| `client_id` | OAuth client id. | `"databricks-cli"` | -| `redirect_port` | Localhost port for the OAuth callback listener. | `8020` | -| `scopes` | OAuth scopes. `offline_access` is required to receive a refresh token (cached and refreshed transparently). | `["all-apis", "offline_access"]` | +| `client_id` | OAuth client id. | `"databricks-sql-connector"` | +| `redirect_port` | Localhost port for the OAuth callback listener. The default app's redirect URI is registered for `http://localhost:8030`. | `8030` | +| `scopes` | OAuth scopes. `offline_access` is required to receive a refresh token (cached and refreshed transparently). | `["sql", "offline_access"]` | | `token_url_override` | Token endpoint override. | OIDC discovery | | `callback_timeout` | How long to wait for the user to complete the browser flow. | `120s` | From a44698f96b94a663120d2738f3065398d8060a50 Mon Sep 17 00:00:00 2001 From: eric-wang-1990 Date: Mon, 17 Aug 2026 18:57:50 -0700 Subject: [PATCH 09/12] docs: minimize README diff to the Configuration link Scope this docs PR to the connection parameter reference: drop the Quick start section and the intro rewrite that had crept into README, leaving a single Configuration section that links to CONNECTION_PARAMETERS.md. Co-authored-by: Isaac Signed-off-by: eric-wang-1990 --- README.md | 54 ++++-------------------------------------------------- 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index d4e8b3a1..70446efb 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,9 @@ Rust client core for Databricks SQL — the shared engine intended to power the Databricks ODBC, Python, Go, and Node.js drivers. -The kernel exposes a Databricks-native v0 async API (`Session` → -`Statement` → `ExecutedStatement` → `ResultStream`, plus a flat `Metadata` -surface) for direct Rust use, the PyO3 (Python) and napi-rs (Node.js) -wrappers, and a C ABI for ODBC / Go consumers. See -[`docs/spec-v0.md`](docs/spec-v0.md) for the API spec. +The kernel is currently exposed via the [ADBC](https://arrow.apache.org/adbc/) +trait surface from `adbc_core`. A native (non-ADBC) Rust API and a stable C +ABI for ODBC/Go consumers are planned. ## Status @@ -37,53 +35,9 @@ cargo test make check # fmt + clippy + tests ``` -## Quick start - -Open a session with the `SessionBuilder`, then run a statement: - -```rust -use databricks_sql_kernel::{Session, AuthConfig, HttpConfig, ExecutedStatementHandle}; - -async fn run() -> Result<(), Box> { -// `HttpConfig` is `#[non_exhaustive]` — construct from the default and -// assign the public fields you want to override: -let mut http = HttpConfig::default(); -http.pool_max_idle_per_host = 200; - -let session = Session::builder() - .http_path("my-workspace.databricks.com", "/sql/1.0/warehouses/abc123") - .auth(AuthConfig::pat(Some(std::env::var("DATABRICKS_TOKEN")?))?) - // optional config groups — omit to accept the defaults below: - .http(http) - .open() - .await?; - -let mut stmt = session.statement(); -stmt.spec().sql("SELECT 1 AS n"); -let mut exec = stmt.execute().await?; - -let stream = exec.result_stream_mut(); -while let Some(_batch) = stream.next_batch().await? { /* consume rows */ } - -exec.close().await?; -session.close().await?; - Ok(()) -} -``` - -Each builder setter takes one config group. `.http_path(host, path)` is -shorthand for a `ConnectionConfig`; `.connection(...)`, `.auth(...)`, -`.defaults(...)`, `.http(...)`, `.proxy(...)`, `.tls(...)`, -`.result(...)`, `.logging(...)`, `.session_conf(...)`, and -`.transport(...)` set the rest. - ## Configuration -A session is configured with a `SessionConfig` — typed sub-structs (one -per concern) passed to `Session::open`. `ConnectionConfig` and `AuthConfig` -are required; the rest are optional. See -[CONNECTION_PARAMETERS.md](CONNECTION_PARAMETERS.md) for every parameter — -its meaning, default value, and the struct it lives on. +See [CONNECTION_PARAMETERS.md](CONNECTION_PARAMETERS.md) for every connection, auth, and session parameter the kernel accepts — its meaning, default value, and the config struct it lives on. ## License From 28bf32fa0817ff4926cb065a192244497aaa7cc0 Mon Sep 17 00:00:00 2001 From: eric-wang-1990 Date: Mon, 17 Aug 2026 19:00:30 -0700 Subject: [PATCH 10/12] docs: refresh README intro to the native v0 API (drop stale ADBC text) Correct the intro in place: the kernel exposes a Databricks-native v0 async API plus PyO3 / napi / C ABI surfaces, not just the ADBC trait surface. Co-authored-by: Isaac Signed-off-by: eric-wang-1990 --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 70446efb..363cc6dd 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,11 @@ Rust client core for Databricks SQL — the shared engine intended to power the Databricks ODBC, Python, Go, and Node.js drivers. -The kernel is currently exposed via the [ADBC](https://arrow.apache.org/adbc/) -trait surface from `adbc_core`. A native (non-ADBC) Rust API and a stable C -ABI for ODBC/Go consumers are planned. +The kernel exposes a Databricks-native v0 async API (`Session` → +`Statement` → `ExecutedStatement` → `ResultStream`, plus a flat `Metadata` +surface) for direct Rust use, the PyO3 (Python) and napi-rs (Node.js) +wrappers, and a C ABI for ODBC / Go consumers. See +[`docs/spec-v0.md`](docs/spec-v0.md) for the API spec. ## Status From 0c581332d7fa226d8e51b86cf6f5ad7d47005378 Mon Sep 17 00:00:00 2001 From: "peco-engineer-bot[bot]" Date: Tue, 18 Aug 2026 02:05:37 +0000 Subject: [PATCH 11/12] ai: apply changes for #184 (1 review thread) Addresses: - #3800367957 at CONNECTION_PARAMETERS.md:192 Signed-off-by: peco-engineer-bot[bot] --- CONNECTION_PARAMETERS.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CONNECTION_PARAMETERS.md b/CONNECTION_PARAMETERS.md index 475bb26f..2e616dd6 100644 --- a/CONNECTION_PARAMETERS.md +++ b/CONNECTION_PARAMETERS.md @@ -187,9 +187,16 @@ wire (they are deliberately *not* in the allowlist). They exist so C ABI (Go / ODBC) consumers can set them through the existing `session_conf` entry point without a dedicated symbol. +Each key mirrors a field of [`ResultConfig`](#resultconfig--result-handling-optional) and is matched **case-insensitively**. Boolean keys accept exactly `"true"` / `"false"` (case-insensitive); the integer window keys require a positive integer. An unrecognised value is rejected with `InvalidArgument` at session creation. + | Key | Description | Default | |-----|-------------|---------| -| `cloudfetch_max_chunks_in_memory` | Same knob as `ResultConfig::cloudfetch_max_chunks_in_memory` — max decompressed CloudFetch chunks held in memory at once. Matched case-insensitively; parse failures / `0` are ignored (default kept), and values above `256` are clamped (peak RSS scales with this, so the ceiling bounds OOM risk). | `16` | +| `cloudfetch_enabled` | Same knob as `ResultConfig::cloudfetch_enabled` — opt into CloudFetch (`false` forces the inline-Arrow path). | `true` | +| `cloudfetch_link_prefetch_window` | Same knob as `ResultConfig::cloudfetch_link_prefetch_window` — number of presigned URLs to prefetch ahead of the consumer. | `10` | +| `cloudfetch_max_chunks_in_memory` | Same knob as `ResultConfig::cloudfetch_max_chunks_in_memory` — max decompressed CloudFetch chunks held in memory at once. Values above `256` are clamped (with a warning) rather than rejected (peak RSS scales with this, so the ceiling bounds OOM risk). | `16` | +| `inline_max_chunks_in_memory` | Same knob as `ResultConfig::inline_max_chunks_in_memory` — prefetch window for the inline-Arrow path. `1` disables prefetching. | `4` | +| `complex_types_as_json` | Same knob as `ResultConfig::complex_types_as_json` — render complex columns as compact JSON strings instead of native Arrow nested types. | `false` | +| `intervals_as_string` | Same knob as `ResultConfig::intervals_as_string` — render `INTERVAL` / `DURATION` columns as canonical Databricks text instead of native Arrow interval types. | `false` | Compression (LZ4) is **not** a parameter: the kernel detects it from the server's result manifest (`result_compression`) and decompresses From 4ff354bfccdedc3a47fb11ece81bc1f6a19a05c9 Mon Sep 17 00:00:00 2001 From: "peco-engineer-bot[bot]" Date: Tue, 18 Aug 2026 02:10:23 +0000 Subject: [PATCH 12/12] ai: apply changes for #184 (1 review thread) Addresses: - #3800385726 at CONNECTION_PARAMETERS.md:160 Signed-off-by: peco-engineer-bot[bot] --- CONNECTION_PARAMETERS.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CONNECTION_PARAMETERS.md b/CONNECTION_PARAMETERS.md index 2e616dd6..6abcec12 100644 --- a/CONNECTION_PARAMETERS.md +++ b/CONNECTION_PARAMETERS.md @@ -157,7 +157,6 @@ for per-parameter meaning and accepted values): | Key | Notes | |-----|-------| | `ANSI_MODE` | Enable/disable ANSI SQL behaviour. | -| `CAN_CLOUD_DOWNLOAD` | Kernel-synthesised from `ResultConfig::cloudfetch_enabled = false`; a user-supplied value (any casing) wins. | | `COLLATION` | Default collation. | | `ENABLE_PHOTON` | Toggle the Photon engine. | | `LEGACY_TIME_PARSER_POLICY` | Legacy datetime parsing behaviour. |