From 43c8c79c9ba15a21b3206adccf922282a4823a23 Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Tue, 10 Nov 2026 23:37:47 +0000 Subject: [PATCH 01/21] fix(kernel): honor the CloudFetch connection option Signed-off-by: Aakash Saravanan --- README.md | 2 +- kernel_config.go | 3 +++ kernel_config_test.go | 25 +++++++++++++++++++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c4633c85..fad7bc25 100644 --- a/README.md +++ b/README.md @@ -327,7 +327,7 @@ parallel via cloud storage | DSN parameter | Connector option | Protocol | Default | Description | |---|---|---|---|---| -| `useCloudFetch` | `WithCloudFetch` | Thrift only (inert on kernel) | `true` | Enable Cloud Fetch. On the kernel path Cloud Fetch is always managed internally, so the flag is inert. | +| `useCloudFetch` | `WithCloudFetch` | Both | `true` | Enable Cloud Fetch. Set to false to fetch results through the SQL connection without direct cloud-storage access. | | `maxDownloadThreads` | `WithMaxDownloadThreads` | Thrift only (inert on kernel) | `10` | Concurrent download goroutines (Thrift). Inert on the kernel path. | | | `WithKernelMaxChunksInMemory(n)` | SEA only | kernel default (16) | Bounds decompressed Cloud Fetch chunks held in memory — trades large-result throughput for peak memory. | diff --git a/kernel_config.go b/kernel_config.go index 9db5d154..83b16dd0 100644 --- a/kernel_config.go +++ b/kernel_config.go @@ -180,6 +180,9 @@ func buildKernelConfig(cfg *config.Config, kauth kernel.Auth) kernel.Config { // An explicit true below opts into native geospatial values. EnableGeoSpatialSupport: false, } + if !cfg.UseCloudFetch { + kc.SessionConf["can_cloud_download"] = "false" + } if cfg.ClientQueryTimeout != nil { timeout := *cfg.ClientQueryTimeout kc.ClientQueryTimeout = &timeout diff --git a/kernel_config_test.go b/kernel_config_test.go index d669a023..122429a3 100644 --- a/kernel_config_test.go +++ b/kernel_config_test.go @@ -473,9 +473,9 @@ var kernelConfigFieldDisposition = map[string]string{ "EnableGeoSpatialSupportDSN": "inert", // DSN carrier; forwarded to KernelExperimental.EnableGeoSpatialSupport // Fields promoted from the embedded CloudFetchConfig. The kernel does - // CloudFetch internally (below the C ABI), so none is forwarded — but each is + // CloudFetch internally (below the C ABI); each option is // classified individually so a new CloudFetch option can't slip the guard. - "UseCloudFetch": "inert", + "UseCloudFetch": "forwarded", "MaxDownloadThreads": "inert", "MaxFilesInMemory": "inert", "MinTimeToExpiry": "inert", @@ -702,6 +702,27 @@ func TestBuildKernelConfig(t *testing.T) { } }) + t.Run("CloudFetch disabled preserves caller session parameters", func(t *testing.T) { + c := baseKernelConfig() + c.UseCloudFetch = false + c.SessionParams = map[string]string{"TIMEZONE": "UTC", "can_cloud_download": "true"} + kc := buildKernelConfig(c, kernel.Auth{Mode: kernel.AuthPAT, Token: "dapi-x"}) + if kc.SessionConf["can_cloud_download"] != "false" || kc.SessionConf["TIMEZONE"] != "UTC" { + t.Fatalf("unexpected session configuration: %v", kc.SessionConf) + } + if c.SessionParams["can_cloud_download"] != "true" { + t.Fatal("caller session parameters were mutated") + } + }) + + t.Run("CloudFetch enabled keeps the server default", func(t *testing.T) { + c := baseKernelConfig() + kc := buildKernelConfig(c, kernel.Auth{Mode: kernel.AuthPAT, Token: "dapi-x"}) + if _, present := kc.SessionConf["can_cloud_download"]; present { + t.Fatalf("unexpected CloudFetch override: %v", kc.SessionConf) + } + }) + t.Run("MaxChunksInMemory injected into kernel SessionConf", func(t *testing.T) { c := baseKernelConfig() c.KernelExperimental = &config.KernelExperimentalConfig{MaxChunksInMemory: 4} From 315fb649349830b522932ed4611cbc717e6a7a72 Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Tue, 10 Nov 2026 23:43:01 +0000 Subject: [PATCH 02/21] docs: describe CloudFetch connection support on both backends Signed-off-by: Aakash Saravanan --- CONNECTION_PARAMETERS.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/CONNECTION_PARAMETERS.md b/CONNECTION_PARAMETERS.md index 35a4ad0e..04bd9500 100644 --- a/CONNECTION_PARAMETERS.md +++ b/CONNECTION_PARAMETERS.md @@ -113,11 +113,9 @@ Notes: - Boolean-valued keys should use the exact strings `"true"` / `"false"` — the kernel does not pre-validate values and forwards them as-is. -- **`CAN_CLOUD_DOWNLOAD` is not a valid SEA session conf**: it may be accepted at - CreateSession and rejected by the first statement with `CONFIG_NOT_AVAILABLE`. - To disable Cloud Fetch on the kernel path, set the client-result conf - `cloudfetch_enabled=false`; `WithCloudFetch(false)` is a Thrift option and is inert - on the kernel path. +- `WithCloudFetch(false)` requests paged inline delivery on the kernel path by + setting `can_cloud_download=false` for the session. The server must support + this capability; unsupported servers return a configuration error. ### Kernel client-result confs @@ -174,7 +172,7 @@ an internal setting) and non-Arrow values also retain legacy session-location pa | DSN parameter | Connector option | Thrift | Kernel | Default | Notes | |---|---|:---:|:---:|---|---| -| `useCloudFetch` | `WithCloudFetch` | ✅ | ⚠️ | `true` | Enable Cloud Fetch on Thrift. This option is inert on the kernel path; use the `cloudfetch_enabled` client-result conf there. | +| `useCloudFetch` | `WithCloudFetch` | ✅ | ✅ | `true` | Set false to fetch complete results through the SQL connection without direct cloud-storage access. | | `maxDownloadThreads` | `WithMaxDownloadThreads` | ✅ | ⚠️ | `10` | Concurrent download goroutines (Thrift). Inert on the kernel path. | | | `WithKernelMaxChunksInMemory(n)` | ❌ | ✅ | kernel default (16) | Bounds decompressed Cloud Fetch chunks held in memory — trades large-result throughput for peak memory. | From 1b17d109656c7b3a7c18242461c2fc0e2f3b875d Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Tue, 10 Nov 2026 23:50:38 +0000 Subject: [PATCH 03/21] test(kernel): verify complete results with CloudFetch disabled Signed-off-by: Aakash Saravanan --- CONNECTION_PARAMETERS.md | 8 ++++++ kernel_cloudfetch_e2e_test.go | 52 +++++++++++++++++++++++++++++++++++ kernel_config.go | 11 +++++++- kernel_config_test.go | 26 ++++++++++-------- 4 files changed, 84 insertions(+), 13 deletions(-) create mode 100644 kernel_cloudfetch_e2e_test.go diff --git a/CONNECTION_PARAMETERS.md b/CONNECTION_PARAMETERS.md index 04bd9500..bd92bd69 100644 --- a/CONNECTION_PARAMETERS.md +++ b/CONNECTION_PARAMETERS.md @@ -176,6 +176,14 @@ an internal setting) and non-Arrow values also retain legacy session-location pa | `maxDownloadThreads` | `WithMaxDownloadThreads` | ✅ | ⚠️ | `10` | Concurrent download goroutines (Thrift). Inert on the kernel path. | | | `WithKernelMaxChunksInMemory(n)` | ❌ | ✅ | kernel default (16) | Bounds decompressed Cloud Fetch chunks held in memory — trades large-result throughput for peak memory. | +On the kernel backend, `WithCloudFetch(false)` requests paged inline results using +`can_cloud_download=false`, as the JDBC driver does. This requires a server that +supports paged inline result delivery. Unsupported servers return a configuration +error; the driver does not fall back to storage downloads. The standard disable +option takes precedence over case-insensitive copies of that session parameter. +The legacy `cloudfetch_enabled=false` client setting selects INLINE Arrow in kernel +1.4.0 and cannot provide this complete large-result behavior. + ## TLS | Connector option | Thrift | Kernel | Notes | diff --git a/kernel_cloudfetch_e2e_test.go b/kernel_cloudfetch_e2e_test.go new file mode 100644 index 00000000..26cf0380 --- /dev/null +++ b/kernel_cloudfetch_e2e_test.go @@ -0,0 +1,52 @@ +//go:build cgo && databricks_kernel + +package dbsql + +import ( + "context" + "crypto/sha256" + "crypto/sha512" + "database/sql" + "fmt" + "strconv" + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +func TestE2EKernelCloudFetchDisabledLargeResults(t *testing.T) { + if testing.Short() { + t.Skip("skipping large inline result in -short mode") + } + host, httpPath, token := pecoTestingCreds(t) + connector, err := NewConnector( + WithServerHostname(host), WithHTTPPath(httpPath), WithAccessToken(token), + WithUseKernel(true), WithCloudFetch(false), + ) + require.NoError(t, err) + db := sql.OpenDB(connector) + defer db.Close() //nolint:errcheck + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute) + defer cancel() + rows, err := db.QueryContext(ctx, "SELECT id, sha2(CAST(id AS STRING), 512) AS payload FROM range(250000) ORDER BY id") + require.NoError(t, err) + defer rows.Close() //nolint:errcheck + var count int64 + var payloadBytes int + digest := sha256.New() + for rows.Next() { + var id int64 + var payload string + require.NoError(t, rows.Scan(&id, &payload)) + require.Equal(t, count, id) + require.Equal(t, fmt.Sprintf("%x", sha512.Sum512([]byte(strconv.FormatInt(id, 10)))), payload) + _, _ = fmt.Fprintf(digest, "%d\t%s\n", id, payload) + payloadBytes += len(payload) + count++ + } + require.NoError(t, rows.Err()) + require.Equal(t, int64(250000), count) + require.Equal(t, 32000000, payloadBytes) + require.Equal(t, "a25ada4c6c476b53e97eb6e8a945e9ce4c14cc432c7ad672dc6fb607d660c86a", fmt.Sprintf("%x", digest.Sum(nil))) +} diff --git a/kernel_config.go b/kernel_config.go index 83b16dd0..2fcba5df 100644 --- a/kernel_config.go +++ b/kernel_config.go @@ -6,6 +6,7 @@ import ( "fmt" "net/url" "strconv" + "strings" "time" "github.com/databricks/databricks-sql-go/auth/noop" @@ -32,6 +33,8 @@ import ( // resolveKernelAuth's U2M case. const u2mKernelClientID = "databricks-sql-connector" +const kernelCloudDownloadConfKey = "can_cloud_download" + func validateClientQueryTimeout(timeout *time.Duration) error { if timeout == nil { return nil @@ -181,7 +184,13 @@ func buildKernelConfig(cfg *config.Config, kauth kernel.Auth) kernel.Config { EnableGeoSpatialSupport: false, } if !cfg.UseCloudFetch { - kc.SessionConf["can_cloud_download"] = "false" + // Paged inline delivery avoids the legacy INLINE result-size limit. + for key := range kc.SessionConf { + if strings.EqualFold(key, kernelCloudDownloadConfKey) { + delete(kc.SessionConf, key) + } + } + kc.SessionConf[kernelCloudDownloadConfKey] = "false" } if cfg.ClientQueryTimeout != nil { timeout := *cfg.ClientQueryTimeout diff --git a/kernel_config_test.go b/kernel_config_test.go index 122429a3..5a1ac40e 100644 --- a/kernel_config_test.go +++ b/kernel_config_test.go @@ -702,18 +702,20 @@ func TestBuildKernelConfig(t *testing.T) { } }) - t.Run("CloudFetch disabled preserves caller session parameters", func(t *testing.T) { - c := baseKernelConfig() - c.UseCloudFetch = false - c.SessionParams = map[string]string{"TIMEZONE": "UTC", "can_cloud_download": "true"} - kc := buildKernelConfig(c, kernel.Auth{Mode: kernel.AuthPAT, Token: "dapi-x"}) - if kc.SessionConf["can_cloud_download"] != "false" || kc.SessionConf["TIMEZONE"] != "UTC" { - t.Fatalf("unexpected session configuration: %v", kc.SessionConf) - } - if c.SessionParams["can_cloud_download"] != "true" { - t.Fatal("caller session parameters were mutated") - } - }) + for _, key := range []string{"can_cloud_download", "CAN_CLOUD_DOWNLOAD", "Can_Cloud_Download"} { + t.Run("CloudFetch disabled overrides "+key, func(t *testing.T) { + c := baseKernelConfig() + c.UseCloudFetch = false + c.SessionParams = map[string]string{"TIMEZONE": "UTC", key: "true"} + kc := buildKernelConfig(c, kernel.Auth{Mode: kernel.AuthPAT, Token: "dapi-x"}) + if kc.SessionConf[kernelCloudDownloadConfKey] != "false" || kc.SessionConf["TIMEZONE"] != "UTC" || len(kc.SessionConf) != 2 { + t.Fatalf("unexpected session configuration: %v", kc.SessionConf) + } + if c.SessionParams[key] != "true" { + t.Fatal("caller session parameters were mutated") + } + }) + } t.Run("CloudFetch enabled keeps the server default", func(t *testing.T) { c := baseKernelConfig() From 87c49fc55a9aa55741b3f6ade3012b977aba020b Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Tue, 10 Nov 2026 23:58:06 +0000 Subject: [PATCH 04/21] test(kernel): block storage access in the inline result test Signed-off-by: Aakash Saravanan --- CHANGELOG.md | 3 +++ CONNECTION_PARAMETERS.md | 2 +- kernel_cloudfetch_e2e_test.go | 36 +++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b736e9a..bc23599c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Release History +## Unreleased +- Honor `WithCloudFetch(false)` / `useCloudFetch=false` on the kernel backend. Complete results use paged inline delivery without storage downloads. Servers without paged inline support return a configuration error at session creation or statement execution; the driver does not fall back to storage downloads. + ## v1.19.0 (2026-11-04) - Upgrade the SQL kernel bindings to v1.4.0. - Upgrade go-oidc to v3.21.0 (go-jose v4.1.6) and x/oauth2 to v0.36.0 to address go-jose/v3 security findings (databricks/databricks-sql-go#526). diff --git a/CONNECTION_PARAMETERS.md b/CONNECTION_PARAMETERS.md index bd92bd69..feb7c793 100644 --- a/CONNECTION_PARAMETERS.md +++ b/CONNECTION_PARAMETERS.md @@ -127,7 +127,7 @@ Thrift options where available. | DSN / session-conf key | Dedicated connector option | Thrift | Kernel | Default | Notes | |---|---|:---:|:---:|---|---| -| `cloudfetch_enabled` | *(none; use `WithSessionParams`)* | ⚠️ | ✅ | `true` | Kernel Cloud Fetch toggle; `false` forces inline results. On Thrift use `WithCloudFetch`. | +| `cloudfetch_enabled` | *(none; use `WithSessionParams`)* | ⚠️ | ✅ | `true` | Kernel Cloud Fetch toggle; `false` forces inline results. Use `WithCloudFetch` on either backend for the standard connection option. | | `cloudfetch_link_prefetch_window` | *(none; use `WithSessionParams`)* | ⚠️ | ✅ | `10` | Number of presigned Cloud Fetch links prefetched ahead of the consumer. | | `cloudfetch_max_chunks_in_memory` | `WithKernelMaxChunksInMemory` | ⚠️ | ✅ | `16` | Maximum decompressed Cloud Fetch chunks held in memory. Values above 256 are clamped with a warning, not rejected. | | `inline_max_chunks_in_memory` | *(none; use `WithSessionParams`)* | ⚠️ | ✅ | `4` | Inline-Arrow prefetch window; `1` disables prefetching. | diff --git a/kernel_cloudfetch_e2e_test.go b/kernel_cloudfetch_e2e_test.go index 26cf0380..3ae0337b 100644 --- a/kernel_cloudfetch_e2e_test.go +++ b/kernel_cloudfetch_e2e_test.go @@ -8,7 +8,12 @@ import ( "crypto/sha512" "database/sql" "fmt" + "io" + "net" + "net/http" + "net/http/httptest" "strconv" + "sync/atomic" "testing" "time" @@ -20,9 +25,38 @@ func TestE2EKernelCloudFetchDisabledLargeResults(t *testing.T) { t.Skip("skipping large inline result in -short mode") } host, httpPath, token := pecoTestingCreds(t) + var workspaceConnections, blockedConnections atomic.Int64 + proxy := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodConnect || r.Host != net.JoinHostPort(host, "443") { + blockedConnections.Add(1) + http.Error(w, "Only the SQL workspace is reachable", http.StatusForbidden) + return + } + upstream, err := net.DialTimeout("tcp", r.Host, 10*time.Second) + if err != nil { + http.Error(w, "Workspace connection failed", http.StatusBadGateway) + return + } + defer upstream.Close() //nolint:errcheck + client, buffered, err := w.(http.Hijacker).Hijack() + if err != nil { + return + } + defer client.Close() //nolint:errcheck + workspaceConnections.Add(1) + _, _ = buffered.WriteString("HTTP/1.1 200 Connection Established\r\n\r\n") + if err := buffered.Flush(); err != nil { + return + } + go func() { _, _ = io.Copy(upstream, buffered) }() + _, _ = io.Copy(client, upstream) + })) + defer proxy.Close() connector, err := NewConnector( WithServerHostname(host), WithHTTPPath(httpPath), WithAccessToken(token), WithUseKernel(true), WithCloudFetch(false), + WithKernelProxy(KernelProxy{URL: proxy.URL}), + WithRetries(-1, time.Millisecond, time.Millisecond), ) require.NoError(t, err) db := sql.OpenDB(connector) @@ -46,6 +80,8 @@ func TestE2EKernelCloudFetchDisabledLargeResults(t *testing.T) { count++ } require.NoError(t, rows.Err()) + require.Positive(t, workspaceConnections.Load(), "SQL traffic must use the restricted proxy") + require.Zero(t, blockedConnections.Load(), "no non-workspace connections are allowed") require.Equal(t, int64(250000), count) require.Equal(t, 32000000, payloadBytes) require.Equal(t, "a25ada4c6c476b53e97eb6e8a945e9ce4c14cc432c7ad672dc6fb607d660c86a", fmt.Sprintf("%x", digest.Sum(nil))) From c7c93456208de30f5f44cc243219a175d3d574b3 Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 00:10:12 +0000 Subject: [PATCH 05/21] fix: give the CloudFetch option precedence over legacy result settings Signed-off-by: Aakash Saravanan --- CONNECTION_PARAMETERS.md | 4 +++- kernel_cloudfetch_e2e_test.go | 1 + kernel_config.go | 2 +- kernel_config_test.go | 24 ++++++++++++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/CONNECTION_PARAMETERS.md b/CONNECTION_PARAMETERS.md index feb7c793..a22d6879 100644 --- a/CONNECTION_PARAMETERS.md +++ b/CONNECTION_PARAMETERS.md @@ -114,7 +114,9 @@ Notes: - Boolean-valued keys should use the exact strings `"true"` / `"false"` — the kernel does not pre-validate values and forwards them as-is. - `WithCloudFetch(false)` requests paged inline delivery on the kernel path by - setting `can_cloud_download=false` for the session. The server must support + setting `can_cloud_download=false` for the session. It takes precedence over + case-insensitive `can_cloud_download` and `cloudfetch_enabled` session parameters. + The server must support this capability; unsupported servers return a configuration error. ### Kernel client-result confs diff --git a/kernel_cloudfetch_e2e_test.go b/kernel_cloudfetch_e2e_test.go index 3ae0337b..43b50674 100644 --- a/kernel_cloudfetch_e2e_test.go +++ b/kernel_cloudfetch_e2e_test.go @@ -55,6 +55,7 @@ func TestE2EKernelCloudFetchDisabledLargeResults(t *testing.T) { connector, err := NewConnector( WithServerHostname(host), WithHTTPPath(httpPath), WithAccessToken(token), WithUseKernel(true), WithCloudFetch(false), + WithSessionParams(map[string]string{"cloudfetch_enabled": "false"}), WithKernelProxy(KernelProxy{URL: proxy.URL}), WithRetries(-1, time.Millisecond, time.Millisecond), ) diff --git a/kernel_config.go b/kernel_config.go index 2fcba5df..ab4270cc 100644 --- a/kernel_config.go +++ b/kernel_config.go @@ -186,7 +186,7 @@ func buildKernelConfig(cfg *config.Config, kauth kernel.Auth) kernel.Config { if !cfg.UseCloudFetch { // Paged inline delivery avoids the legacy INLINE result-size limit. for key := range kc.SessionConf { - if strings.EqualFold(key, kernelCloudDownloadConfKey) { + if strings.EqualFold(key, kernelCloudDownloadConfKey) || strings.EqualFold(key, "cloudfetch_enabled") { delete(kc.SessionConf, key) } } diff --git a/kernel_config_test.go b/kernel_config_test.go index 5a1ac40e..f461bb2b 100644 --- a/kernel_config_test.go +++ b/kernel_config_test.go @@ -725,6 +725,30 @@ func TestBuildKernelConfig(t *testing.T) { } }) + for _, key := range []string{"cloudfetch_enabled", "CLOUDFETCH_ENABLED"} { + t.Run("CloudFetch disabled overrides legacy "+key, func(t *testing.T) { + c := baseKernelConfig() + c.UseCloudFetch = false + c.SessionParams = map[string]string{key: "false", "TIMEZONE": "UTC"} + kc := buildKernelConfig(c, kernel.Auth{Mode: kernel.AuthPAT, Token: "dapi-x"}) + if kc.SessionConf[kernelCloudDownloadConfKey] != "false" || kc.SessionConf["TIMEZONE"] != "UTC" || len(kc.SessionConf) != 2 { + t.Fatalf("unexpected session configuration: %v", kc.SessionConf) + } + if c.SessionParams[key] != "false" { + t.Fatal("caller session parameters were mutated") + } + }) + } + + t.Run("CloudFetch enabled preserves explicit session parameters", func(t *testing.T) { + c := baseKernelConfig() + c.SessionParams = map[string]string{"CAN_CLOUD_DOWNLOAD": "false", "cloudfetch_enabled": "false", "TIMEZONE": "UTC"} + kc := buildKernelConfig(c, kernel.Auth{Mode: kernel.AuthPAT, Token: "dapi-x"}) + if !reflect.DeepEqual(kc.SessionConf, c.SessionParams) { + t.Fatalf("session parameters changed: %v", kc.SessionConf) + } + }) + t.Run("MaxChunksInMemory injected into kernel SessionConf", func(t *testing.T) { c := baseKernelConfig() c.KernelExperimental = &config.KernelExperimentalConfig{MaxChunksInMemory: 4} From 52efc7ff33b71b34183537e11a6326dd16d7afeb Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 00:18:48 +0000 Subject: [PATCH 06/21] test: clarify CloudFetch configuration precedence Signed-off-by: Aakash Saravanan --- CHANGELOG.md | 2 +- kernel_cloudfetch_e2e_test.go | 7 ++++++- kernel_config_test.go | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc23599c..c59d6c25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Release History ## Unreleased -- Honor `WithCloudFetch(false)` / `useCloudFetch=false` on the kernel backend. Complete results use paged inline delivery without storage downloads. Servers without paged inline support return a configuration error at session creation or statement execution; the driver does not fall back to storage downloads. +- **Behavior change:** Honor `WithCloudFetch(false)` / `useCloudFetch=false` on the kernel backend, taking precedence over raw `can_cloud_download` and `cloudfetch_enabled` session parameters. Complete results use paged inline delivery without storage downloads. Servers without paged inline support return a configuration error at session creation or statement execution; the driver does not fall back to storage downloads. ## v1.19.0 (2026-11-04) - Upgrade the SQL kernel bindings to v1.4.0. diff --git a/kernel_cloudfetch_e2e_test.go b/kernel_cloudfetch_e2e_test.go index 43b50674..687ff9ad 100644 --- a/kernel_cloudfetch_e2e_test.go +++ b/kernel_cloudfetch_e2e_test.go @@ -38,7 +38,12 @@ func TestE2EKernelCloudFetchDisabledLargeResults(t *testing.T) { return } defer upstream.Close() //nolint:errcheck - client, buffered, err := w.(http.Hijacker).Hijack() + hijacker, ok := w.(http.Hijacker) + if !ok { + http.Error(w, "Proxy tunneling is unavailable", http.StatusInternalServerError) + return + } + client, buffered, err := hijacker.Hijack() if err != nil { return } diff --git a/kernel_config_test.go b/kernel_config_test.go index f461bb2b..d7648fdb 100644 --- a/kernel_config_test.go +++ b/kernel_config_test.go @@ -719,6 +719,7 @@ func TestBuildKernelConfig(t *testing.T) { t.Run("CloudFetch enabled keeps the server default", func(t *testing.T) { c := baseKernelConfig() + c.UseCloudFetch = true kc := buildKernelConfig(c, kernel.Auth{Mode: kernel.AuthPAT, Token: "dapi-x"}) if _, present := kc.SessionConf["can_cloud_download"]; present { t.Fatalf("unexpected CloudFetch override: %v", kc.SessionConf) @@ -742,6 +743,7 @@ func TestBuildKernelConfig(t *testing.T) { t.Run("CloudFetch enabled preserves explicit session parameters", func(t *testing.T) { c := baseKernelConfig() + c.UseCloudFetch = true c.SessionParams = map[string]string{"CAN_CLOUD_DOWNLOAD": "false", "cloudfetch_enabled": "false", "TIMEZONE": "UTC"} kc := buildKernelConfig(c, kernel.Auth{Mode: kernel.AuthPAT, Token: "dapi-x"}) if !reflect.DeepEqual(kc.SessionConf, c.SessionParams) { From 2577513f59c5c2c8cc95db65f9d72986bdf7bb49 Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 00:27:05 +0000 Subject: [PATCH 07/21] test: preserve unsupported result-delivery errors Signed-off-by: Aakash Saravanan --- kernel_cloudfetch_e2e_test.go | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/kernel_cloudfetch_e2e_test.go b/kernel_cloudfetch_e2e_test.go index 687ff9ad..c2ad0409 100644 --- a/kernel_cloudfetch_e2e_test.go +++ b/kernel_cloudfetch_e2e_test.go @@ -7,19 +7,66 @@ import ( "crypto/sha256" "crypto/sha512" "database/sql" + "encoding/json" "fmt" "io" "net" "net/http" "net/http/httptest" "strconv" + "strings" "sync/atomic" "testing" "time" + dbsqlerr "github.com/databricks/databricks-sql-go/errors" "github.com/stretchr/testify/require" ) +func TestKernelCloudFetchDisabledPreservesUnsupportedServerError(t *testing.T) { + var executions atomic.Int64 + server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + switch { + case r.Method == http.MethodPost && strings.HasSuffix(r.URL.Path, "/sessions"): + var body struct { + SessionConfs map[string]string `json:"session_confs"` + } + if err := json.NewDecoder(r.Body).Decode(&body); err != nil || body.SessionConfs["can_cloud_download"] != "false" { + http.Error(w, "missing disabled download capability", http.StatusBadRequest) + return + } + _, _ = io.WriteString(w, `{"session_id":"test-session"}`) + case r.Method == http.MethodPost && strings.HasSuffix(r.URL.Path, "/statements"): + executions.Add(1) + _, _ = io.WriteString(w, `{"statement_id":"unsupported-inline","status":{"state":"FAILED","sql_state":"42K0I","error":{"error_code":"CONFIG_NOT_AVAILABLE","message":"Configuration can_cloud_download is not available"}}}`) + default: + _, _ = io.WriteString(w, `{}`) + } + })) + defer server.Close() + connector, err := NewConnector( + WithServerHostname(server.URL), WithHTTPPath("/sql/1.0/warehouses/test"), + WithAccessToken("test-token"), WithUseKernel(true), WithCloudFetch(false), + WithSkipTLSHostVerify(), WithRetries(-1, time.Millisecond, time.Millisecond), + ) + require.NoError(t, err) + db := sql.OpenDB(connector) + defer db.Close() //nolint:errcheck + ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) + defer cancel() + connection, err := db.Conn(ctx) + require.NoError(t, err) + defer connection.Close() //nolint:errcheck + _, err = connection.ExecContext(ctx, "SELECT 1") + require.Error(t, err) + var executionError dbsqlerr.DBExecutionError + require.ErrorAs(t, err, &executionError) + require.Equal(t, "42K0I", executionError.SqlState()) + require.Contains(t, err.Error(), "CONFIG_NOT_AVAILABLE") + require.Equal(t, int64(1), executions.Load(), "unsupported delivery must not fall back") +} + func TestE2EKernelCloudFetchDisabledLargeResults(t *testing.T) { if testing.Short() { t.Skip("skipping large inline result in -short mode") From 1f1218a9b0bf3fc5f8c5003e687a54f8ce08185a Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 00:36:29 +0000 Subject: [PATCH 08/21] fix: surface conflicting CloudFetch settings during backend recovery Signed-off-by: Aakash Saravanan --- CHANGELOG.md | 2 +- connector_reyden_test.go | 5 +++ kernel_cloudfetch_e2e_test.go | 47 -------------------------- kernel_cloudfetch_test.go | 62 +++++++++++++++++++++++++++++++++++ kernel_config.go | 6 +++- 5 files changed, 73 insertions(+), 49 deletions(-) create mode 100644 kernel_cloudfetch_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index c59d6c25..dfa54899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Release History ## Unreleased -- **Behavior change:** Honor `WithCloudFetch(false)` / `useCloudFetch=false` on the kernel backend, taking precedence over raw `can_cloud_download` and `cloudfetch_enabled` session parameters. Complete results use paged inline delivery without storage downloads. Servers without paged inline support return a configuration error at session creation or statement execution; the driver does not fall back to storage downloads. +- **Behavior change:** Honor `WithCloudFetch(false)` / `useCloudFetch=false` on the kernel backend, taking precedence over raw `can_cloud_download` and `cloudfetch_enabled` session parameters. Complete results use paged inline delivery without storage downloads. Servers without paged inline support return a configuration error at session creation or statement execution; the driver does not fall back to storage downloads. This also applies when a connection automatically switches to the kernel backend after a protocol rejection. ## v1.19.0 (2026-11-04) - Upgrade the SQL kernel bindings to v1.4.0. diff --git a/connector_reyden_test.go b/connector_reyden_test.go index 92cfe1af..630d0d6b 100644 --- a/connector_reyden_test.go +++ b/connector_reyden_test.go @@ -8,6 +8,7 @@ import ( dbsqlerr "github.com/databricks/databricks-sql-go/errors" "github.com/databricks/databricks-sql-go/internal/backend" + "github.com/databricks/databricks-sql-go/internal/backend/kernel" "github.com/databricks/databricks-sql-go/internal/backend/thrift" "github.com/databricks/databricks-sql-go/internal/cli_service" "github.com/databricks/databricks-sql-go/internal/client" @@ -193,10 +194,14 @@ func TestReydenReactiveRecovery(t *testing.T) { return fakeThrift, nil }, func(ctx context.Context, cfg *config.Config) (backend.Backend, error) { + require.False(t, cfg.UseCloudFetch) + kc := buildKernelConfig(cfg, kernel.Auth{Mode: kernel.AuthPAT, Token: "test-token"}) + require.Equal(t, "false", kc.SessionConf[kernelCloudDownloadConfKey]) return kernelBackend, nil }, ) + conn.cfg.UseCloudFetch = false be, _, err := conn.openSessionWithReydenFallback(context.Background()) require.NoError(t, err) diff --git a/kernel_cloudfetch_e2e_test.go b/kernel_cloudfetch_e2e_test.go index c2ad0409..687ff9ad 100644 --- a/kernel_cloudfetch_e2e_test.go +++ b/kernel_cloudfetch_e2e_test.go @@ -7,66 +7,19 @@ import ( "crypto/sha256" "crypto/sha512" "database/sql" - "encoding/json" "fmt" "io" "net" "net/http" "net/http/httptest" "strconv" - "strings" "sync/atomic" "testing" "time" - dbsqlerr "github.com/databricks/databricks-sql-go/errors" "github.com/stretchr/testify/require" ) -func TestKernelCloudFetchDisabledPreservesUnsupportedServerError(t *testing.T) { - var executions atomic.Int64 - server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - switch { - case r.Method == http.MethodPost && strings.HasSuffix(r.URL.Path, "/sessions"): - var body struct { - SessionConfs map[string]string `json:"session_confs"` - } - if err := json.NewDecoder(r.Body).Decode(&body); err != nil || body.SessionConfs["can_cloud_download"] != "false" { - http.Error(w, "missing disabled download capability", http.StatusBadRequest) - return - } - _, _ = io.WriteString(w, `{"session_id":"test-session"}`) - case r.Method == http.MethodPost && strings.HasSuffix(r.URL.Path, "/statements"): - executions.Add(1) - _, _ = io.WriteString(w, `{"statement_id":"unsupported-inline","status":{"state":"FAILED","sql_state":"42K0I","error":{"error_code":"CONFIG_NOT_AVAILABLE","message":"Configuration can_cloud_download is not available"}}}`) - default: - _, _ = io.WriteString(w, `{}`) - } - })) - defer server.Close() - connector, err := NewConnector( - WithServerHostname(server.URL), WithHTTPPath("/sql/1.0/warehouses/test"), - WithAccessToken("test-token"), WithUseKernel(true), WithCloudFetch(false), - WithSkipTLSHostVerify(), WithRetries(-1, time.Millisecond, time.Millisecond), - ) - require.NoError(t, err) - db := sql.OpenDB(connector) - defer db.Close() //nolint:errcheck - ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) - defer cancel() - connection, err := db.Conn(ctx) - require.NoError(t, err) - defer connection.Close() //nolint:errcheck - _, err = connection.ExecContext(ctx, "SELECT 1") - require.Error(t, err) - var executionError dbsqlerr.DBExecutionError - require.ErrorAs(t, err, &executionError) - require.Equal(t, "42K0I", executionError.SqlState()) - require.Contains(t, err.Error(), "CONFIG_NOT_AVAILABLE") - require.Equal(t, int64(1), executions.Load(), "unsupported delivery must not fall back") -} - func TestE2EKernelCloudFetchDisabledLargeResults(t *testing.T) { if testing.Short() { t.Skip("skipping large inline result in -short mode") diff --git a/kernel_cloudfetch_test.go b/kernel_cloudfetch_test.go new file mode 100644 index 00000000..297b4da2 --- /dev/null +++ b/kernel_cloudfetch_test.go @@ -0,0 +1,62 @@ +//go:build cgo && databricks_kernel + +package dbsql + +import ( + "context" + "database/sql" + "encoding/json" + dbsqlerr "github.com/databricks/databricks-sql-go/errors" + "github.com/stretchr/testify/require" + "io" + "net/http" + "net/http/httptest" + "strings" + "sync/atomic" + "testing" + "time" +) + +func TestKernelCloudFetchDisabledPreservesUnsupportedServerError(t *testing.T) { + var executions atomic.Int64 + server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + switch { + case r.Method == http.MethodPost && strings.HasSuffix(r.URL.Path, "/sessions"): + var body struct { + SessionConfs map[string]string `json:"session_confs"` + } + if err := json.NewDecoder(r.Body).Decode(&body); err != nil || body.SessionConfs["can_cloud_download"] != "false" { + http.Error(w, "missing disabled download capability", http.StatusBadRequest) + return + } + _, _ = io.WriteString(w, `{"session_id":"test-session"}`) + case r.Method == http.MethodPost && strings.HasSuffix(r.URL.Path, "/statements"): + executions.Add(1) + _, _ = io.WriteString(w, `{"statement_id":"unsupported-inline","status":{"state":"FAILED","sql_state":"42K0I","error":{"error_code":"CONFIG_NOT_AVAILABLE","message":"Configuration can_cloud_download is not available"}}}`) + default: + _, _ = io.WriteString(w, `{}`) + } + })) + defer server.Close() + connector, err := NewConnector( + WithServerHostname(server.URL), WithHTTPPath("/sql/1.0/warehouses/test"), + WithAccessToken("test-token"), WithUseKernel(true), WithCloudFetch(false), + WithSkipTLSHostVerify(), WithRetries(-1, time.Millisecond, time.Millisecond), + ) + require.NoError(t, err) + db := sql.OpenDB(connector) + defer db.Close() //nolint:errcheck + ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) + defer cancel() + connection, err := db.Conn(ctx) + require.NoError(t, err) + defer connection.Close() //nolint:errcheck + _, err = connection.ExecContext(ctx, "SELECT 1") + require.Error(t, err) + var executionError dbsqlerr.DBExecutionError + require.ErrorAs(t, err, &executionError) + require.Equal(t, "42K0I", executionError.SqlState()) + require.Contains(t, err.Error(), "CONFIG_NOT_AVAILABLE") + require.Equal(t, int64(1), executions.Load(), "unsupported delivery must not fall back") +} diff --git a/kernel_config.go b/kernel_config.go index ab4270cc..fa26e06e 100644 --- a/kernel_config.go +++ b/kernel_config.go @@ -15,6 +15,7 @@ import ( "github.com/databricks/databricks-sql-go/internal/backend/kernel" "github.com/databricks/databricks-sql-go/internal/client" "github.com/databricks/databricks-sql-go/internal/config" + "github.com/databricks/databricks-sql-go/logger" "github.com/databricks/databricks-sql-go/telemetry" ) @@ -185,8 +186,11 @@ func buildKernelConfig(cfg *config.Config, kauth kernel.Auth) kernel.Config { } if !cfg.UseCloudFetch { // Paged inline delivery avoids the legacy INLINE result-size limit. - for key := range kc.SessionConf { + for key, value := range kc.SessionConf { if strings.EqualFold(key, kernelCloudDownloadConfKey) || strings.EqualFold(key, "cloudfetch_enabled") { + if strings.EqualFold(key, "cloudfetch_enabled") || !strings.EqualFold(value, "false") { + logger.Warn().Msgf("WithCloudFetch(false) overrides session parameter %q", key) + } delete(kc.SessionConf, key) } } From abf8398f565125add4e8e9148b3f1d0181241eaf Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 00:39:06 +0000 Subject: [PATCH 09/21] refactor: name the legacy CloudFetch configuration key Signed-off-by: Aakash Saravanan --- kernel_config.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel_config.go b/kernel_config.go index fa26e06e..580334df 100644 --- a/kernel_config.go +++ b/kernel_config.go @@ -35,6 +35,7 @@ import ( const u2mKernelClientID = "databricks-sql-connector" const kernelCloudDownloadConfKey = "can_cloud_download" +const kernelCloudFetchEnabledConfKey = "cloudfetch_enabled" func validateClientQueryTimeout(timeout *time.Duration) error { if timeout == nil { @@ -187,8 +188,8 @@ func buildKernelConfig(cfg *config.Config, kauth kernel.Auth) kernel.Config { if !cfg.UseCloudFetch { // Paged inline delivery avoids the legacy INLINE result-size limit. for key, value := range kc.SessionConf { - if strings.EqualFold(key, kernelCloudDownloadConfKey) || strings.EqualFold(key, "cloudfetch_enabled") { - if strings.EqualFold(key, "cloudfetch_enabled") || !strings.EqualFold(value, "false") { + if strings.EqualFold(key, kernelCloudDownloadConfKey) || strings.EqualFold(key, kernelCloudFetchEnabledConfKey) { + if strings.EqualFold(key, kernelCloudFetchEnabledConfKey) || !strings.EqualFold(value, "false") { logger.Warn().Msgf("WithCloudFetch(false) overrides session parameter %q", key) } delete(kc.SessionConf, key) From b28e34812f011cea380a427bb63c1b9d6a502a5b Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 00:44:41 +0000 Subject: [PATCH 10/21] test: preserve disabled downloads during backend recovery Signed-off-by: Aakash Saravanan --- kernel_cloudfetch_test.go | 82 ++++++++++++++++++++++++++++++++------- kernel_config.go | 4 +- 2 files changed, 72 insertions(+), 14 deletions(-) diff --git a/kernel_cloudfetch_test.go b/kernel_cloudfetch_test.go index 297b4da2..0e29c644 100644 --- a/kernel_cloudfetch_test.go +++ b/kernel_cloudfetch_test.go @@ -6,8 +6,7 @@ import ( "context" "database/sql" "encoding/json" - dbsqlerr "github.com/databricks/databricks-sql-go/errors" - "github.com/stretchr/testify/require" + "fmt" "io" "net/http" "net/http/httptest" @@ -15,14 +14,36 @@ import ( "sync/atomic" "testing" "time" + + dbsqlerr "github.com/databricks/databricks-sql-go/errors" + "github.com/databricks/databricks-sql-go/internal/backend" + "github.com/databricks/databricks-sql-go/internal/cli_service" + "github.com/databricks/databricks-sql-go/internal/client" + "github.com/databricks/databricks-sql-go/internal/config" + "github.com/databricks/databricks-sql-go/internal/warehouse_cache" + "github.com/stretchr/testify/require" ) func TestKernelCloudFetchDisabledPreservesUnsupportedServerError(t *testing.T) { + for _, automaticRecovery := range []bool{false, true} { + for _, rejectSession := range []bool{false, true} { + t.Run(fmt.Sprintf("recovery=%t/session_rejected=%t", automaticRecovery, rejectSession), func(t *testing.T) { + testKernelCloudFetchDisabledUnsupportedServer(t, automaticRecovery, rejectSession) + }) + } + } +} + +func testKernelCloudFetchDisabledUnsupportedServer(t *testing.T, automaticRecovery, rejectSession bool) { + t.Helper() + defer warehouse_cache.ClearCache() + var sessions atomic.Int64 var executions atomic.Int64 server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") switch { case r.Method == http.MethodPost && strings.HasSuffix(r.URL.Path, "/sessions"): + sessions.Add(1) var body struct { SessionConfs map[string]string `json:"session_confs"` } @@ -30,6 +51,17 @@ func TestKernelCloudFetchDisabledPreservesUnsupportedServerError(t *testing.T) { http.Error(w, "missing disabled download capability", http.StatusBadRequest) return } + for key := range body.SessionConfs { + if strings.EqualFold(key, "cloudfetch_enabled") || (strings.EqualFold(key, "can_cloud_download") && key != "can_cloud_download") { + http.Error(w, "conflicting download parameter", http.StatusBadRequest) + return + } + } + if rejectSession { + w.WriteHeader(http.StatusBadRequest) + _, _ = io.WriteString(w, `{"error_code":"CONFIG_NOT_AVAILABLE","message":"Configuration can_cloud_download is not available. SQLSTATE: 42K0I"}`) + return + } _, _ = io.WriteString(w, `{"session_id":"test-session"}`) case r.Method == http.MethodPost && strings.HasSuffix(r.URL.Path, "/statements"): executions.Add(1) @@ -39,24 +71,48 @@ func TestKernelCloudFetchDisabledPreservesUnsupportedServerError(t *testing.T) { } })) defer server.Close() - connector, err := NewConnector( + dbConnector, err := NewConnector( WithServerHostname(server.URL), WithHTTPPath("/sql/1.0/warehouses/test"), WithAccessToken("test-token"), WithUseKernel(true), WithCloudFetch(false), + WithSessionParams(map[string]string{"cloudfetch_enabled": "false", "CAN_CLOUD_DOWNLOAD": "true"}), WithSkipTLSHostVerify(), WithRetries(-1, time.Millisecond, time.Millisecond), ) require.NoError(t, err) - db := sql.OpenDB(connector) + var thriftAttempts atomic.Int64 + if automaticRecovery { + c := dbConnector.(*connector) + c.cfg.UseKernel = false + c.thriftBackendFactory = func(context.Context, *config.Config, *http.Client) (backend.Backend, error) { + thriftAttempts.Add(1) + sqlState := "KP001" + return &fakeThriftBackend{openSessionErr: client.CheckOpenSessionStatus(&cli_service.TOpenSessionResp{ + Status: &cli_service.TStatus{StatusCode: cli_service.TStatusCode_ERROR_STATUS, SqlState: &sqlState}, + })}, nil + } + } + db := sql.OpenDB(dbConnector) defer db.Close() //nolint:errcheck ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) defer cancel() connection, err := db.Conn(ctx) - require.NoError(t, err) - defer connection.Close() //nolint:errcheck - _, err = connection.ExecContext(ctx, "SELECT 1") - require.Error(t, err) - var executionError dbsqlerr.DBExecutionError - require.ErrorAs(t, err, &executionError) - require.Equal(t, "42K0I", executionError.SqlState()) - require.Contains(t, err.Error(), "CONFIG_NOT_AVAILABLE") - require.Equal(t, int64(1), executions.Load(), "unsupported delivery must not fall back") + if rejectSession { + require.Error(t, err) + require.Contains(t, err.Error(), "CONFIG_NOT_AVAILABLE") + require.Contains(t, err.Error(), "42K0I") + require.Equal(t, int64(0), executions.Load()) + } else { + require.NoError(t, err) + defer connection.Close() //nolint:errcheck + _, err = connection.ExecContext(ctx, "SELECT 1") + require.Error(t, err) + var executionError dbsqlerr.DBExecutionError + require.ErrorAs(t, err, &executionError) + require.Equal(t, "42K0I", executionError.SqlState()) + require.Contains(t, err.Error(), "CONFIG_NOT_AVAILABLE") + require.Equal(t, int64(1), executions.Load(), "unsupported delivery must not fall back") + } + require.Equal(t, int64(1), sessions.Load(), "unsupported delivery must not reopen the session") + if automaticRecovery { + require.Equal(t, int64(1), thriftAttempts.Load(), "backend recovery must not repeat") + } } diff --git a/kernel_config.go b/kernel_config.go index 580334df..c4bd0e00 100644 --- a/kernel_config.go +++ b/kernel_config.go @@ -189,7 +189,9 @@ func buildKernelConfig(cfg *config.Config, kauth kernel.Auth) kernel.Config { // Paged inline delivery avoids the legacy INLINE result-size limit. for key, value := range kc.SessionConf { if strings.EqualFold(key, kernelCloudDownloadConfKey) || strings.EqualFold(key, kernelCloudFetchEnabledConfKey) { - if strings.EqualFold(key, kernelCloudFetchEnabledConfKey) || !strings.EqualFold(value, "false") { + if strings.EqualFold(key, kernelCloudFetchEnabledConfKey) { + logger.Warn().Msgf("WithCloudFetch(false) replaces legacy INLINE session parameter %q with paged inline delivery", key) + } else if !strings.EqualFold(value, "false") { logger.Warn().Msgf("WithCloudFetch(false) overrides session parameter %q", key) } delete(kc.SessionConf, key) From 7356c8de8d8dd21bc15b05cff5fdb4a4ae726adc Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 00:48:47 +0000 Subject: [PATCH 11/21] fix: limit CloudFetch configuration warnings Signed-off-by: Aakash Saravanan --- kernel_config.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel_config.go b/kernel_config.go index c4bd0e00..9a62542b 100644 --- a/kernel_config.go +++ b/kernel_config.go @@ -7,6 +7,7 @@ import ( "net/url" "strconv" "strings" + "sync" "time" "github.com/databricks/databricks-sql-go/auth/noop" @@ -37,6 +38,8 @@ const u2mKernelClientID = "databricks-sql-connector" const kernelCloudDownloadConfKey = "can_cloud_download" const kernelCloudFetchEnabledConfKey = "cloudfetch_enabled" +var kernelCloudFetchOverrideWarnOnce sync.Once + func validateClientQueryTimeout(timeout *time.Duration) error { if timeout == nil { return nil @@ -189,10 +192,10 @@ func buildKernelConfig(cfg *config.Config, kauth kernel.Auth) kernel.Config { // Paged inline delivery avoids the legacy INLINE result-size limit. for key, value := range kc.SessionConf { if strings.EqualFold(key, kernelCloudDownloadConfKey) || strings.EqualFold(key, kernelCloudFetchEnabledConfKey) { - if strings.EqualFold(key, kernelCloudFetchEnabledConfKey) { - logger.Warn().Msgf("WithCloudFetch(false) replaces legacy INLINE session parameter %q with paged inline delivery", key) - } else if !strings.EqualFold(value, "false") { - logger.Warn().Msgf("WithCloudFetch(false) overrides session parameter %q", key) + if strings.EqualFold(key, kernelCloudFetchEnabledConfKey) || !strings.EqualFold(value, "false") { + kernelCloudFetchOverrideWarnOnce.Do(func() { + logger.Warn().Msg("WithCloudFetch(false) overrides raw CloudFetch session parameters to request complete inline results") + }) } delete(kc.SessionConf, key) } From ff05afcd39ad4e42f1f0c5e4b461d0ec60abf34d Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 00:52:24 +0000 Subject: [PATCH 12/21] docs: explain migration from legacy inline configuration Signed-off-by: Aakash Saravanan --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfa54899..9a28a7ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased - **Behavior change:** Honor `WithCloudFetch(false)` / `useCloudFetch=false` on the kernel backend, taking precedence over raw `can_cloud_download` and `cloudfetch_enabled` session parameters. Complete results use paged inline delivery without storage downloads. Servers without paged inline support return a configuration error at session creation or statement execution; the driver does not fall back to storage downloads. This also applies when a connection automatically switches to the kernel backend after a protocol rejection. + Configurations combining `WithCloudFetch(false)` with the previously documented `cloudfetch_enabled=false` now require a warehouse with paged inline support. To retain the legacy INLINE behavior on an unsupported warehouse, remove `WithCloudFetch(false)` / `useCloudFetch=false` and keep only the raw session parameter; that legacy mode has a result-size limit and does not guarantee complete large results. Configurations using only the raw parameter retain their existing behavior. ## v1.19.0 (2026-11-04) - Upgrade the SQL kernel bindings to v1.4.0. From 2950a4b6697f01c33c3bb361a917a975dbdb8716 Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 00:58:38 +0000 Subject: [PATCH 13/21] fix: identify overridden CloudFetch configuration keys Signed-off-by: Aakash Saravanan --- kernel_config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel_config.go b/kernel_config.go index 9a62542b..c8c55316 100644 --- a/kernel_config.go +++ b/kernel_config.go @@ -194,7 +194,7 @@ func buildKernelConfig(cfg *config.Config, kauth kernel.Auth) kernel.Config { if strings.EqualFold(key, kernelCloudDownloadConfKey) || strings.EqualFold(key, kernelCloudFetchEnabledConfKey) { if strings.EqualFold(key, kernelCloudFetchEnabledConfKey) || !strings.EqualFold(value, "false") { kernelCloudFetchOverrideWarnOnce.Do(func() { - logger.Warn().Msg("WithCloudFetch(false) overrides raw CloudFetch session parameters to request complete inline results") + logger.Warn().Msg("WithCloudFetch(false) overrides raw can_cloud_download and cloudfetch_enabled session parameters for complete inline results") }) } delete(kc.SessionConf, key) From c091a5e6122db6d7f3e704392dc2a811bf9a3c6f Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 01:16:22 +0000 Subject: [PATCH 14/21] test: cover CloudFetch configuration migration warnings Signed-off-by: Aakash Saravanan --- kernel_config_test.go | 61 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/kernel_config_test.go b/kernel_config_test.go index d7648fdb..62c422e9 100644 --- a/kernel_config_test.go +++ b/kernel_config_test.go @@ -1,10 +1,14 @@ package dbsql import ( + "bytes" "crypto/tls" "errors" "net/http" + "os" "reflect" + "strings" + "sync" "testing" "time" @@ -14,8 +18,65 @@ import ( "github.com/databricks/databricks-sql-go/internal/backend/kernel" "github.com/databricks/databricks-sql-go/internal/client" "github.com/databricks/databricks-sql-go/internal/config" + "github.com/databricks/databricks-sql-go/logger" ) +func TestBuildKernelConfigCloudFetchOverrideWarning(t *testing.T) { + previousLevel := logger.Logger.GetLevel() + t.Cleanup(func() { + logger.SetLogOutput(os.Stderr) + logger.Logger.Logger = logger.Logger.Level(previousLevel) + kernelCloudFetchOverrideWarnOnce = sync.Once{} + }) + if err := logger.SetLogLevel("warn"); err != nil { + t.Fatal(err) + } + + for _, tc := range []struct { + name string + enabled bool + params map[string]string + warn bool + }{ + {name: "no raw configuration"}, + {name: "matching capability", params: map[string]string{"CAN_CLOUD_DOWNLOAD": "FALSE"}}, + {name: "conflicting capability", params: map[string]string{"Can_Cloud_Download": "true"}, warn: true}, + {name: "private value", params: map[string]string{"can_cloud_download": "private-setting-value"}, warn: true}, + {name: "legacy disabled", params: map[string]string{"CLOUDFETCH_ENABLED": "false"}, warn: true}, + {name: "legacy enabled", params: map[string]string{"cloudfetch_enabled": "true"}, warn: true}, + {name: "enabled preserves raw configuration", enabled: true, params: map[string]string{"can_cloud_download": "true", "cloudfetch_enabled": "false"}}, + {name: "unrelated parameter", params: map[string]string{"TIMEZONE": "UTC"}}, + } { + t.Run(tc.name, func(t *testing.T) { + kernelCloudFetchOverrideWarnOnce = sync.Once{} + var output bytes.Buffer + logger.SetLogOutput(&output) + cfg := baseKernelConfig() + cfg.UseCloudFetch = tc.enabled + cfg.SessionParams = tc.params + buildKernelConfig(cfg, kernel.Auth{}) + first := output.String() + wantWarnings := 0 + if tc.warn { + wantWarnings = 1 + } + if got := strings.Count(first, `"level":"warn"`); got != wantWarnings { + t.Fatalf("warning count = %d, want %d: %s", got, wantWarnings, first) + } + if tc.warn && (!strings.Contains(first, "can_cloud_download") || !strings.Contains(first, "cloudfetch_enabled")) { + t.Fatalf("warning does not name both overridden settings: %s", first) + } + if strings.Contains(first, "private-setting-value") { + t.Fatal("warning exposes a raw parameter value") + } + buildKernelConfig(cfg, kernel.Auth{}) + if output.String() != first { + t.Fatal("warning repeated for a second configuration") + } + }) + } +} + // nonPATAuth stands in for any non-PAT, non-OAuth authenticator (token-provider / // external / static) — the kernel backend must reject it. It implements neither // kernel.M2MCredentialsProvider nor kernel.U2MCredentialsProvider. From 3ef7e8574bb964d494f51820d4cfdbe7e9ce56ff Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 01:18:55 +0000 Subject: [PATCH 15/21] docs: clarify migration for existing CloudFetch disable options Signed-off-by: Aakash Saravanan --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a28a7ed..08fd0dac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased - **Behavior change:** Honor `WithCloudFetch(false)` / `useCloudFetch=false` on the kernel backend, taking precedence over raw `can_cloud_download` and `cloudfetch_enabled` session parameters. Complete results use paged inline delivery without storage downloads. Servers without paged inline support return a configuration error at session creation or statement execution; the driver does not fall back to storage downloads. This also applies when a connection automatically switches to the kernel backend after a protocol rejection. - Configurations combining `WithCloudFetch(false)` with the previously documented `cloudfetch_enabled=false` now require a warehouse with paged inline support. To retain the legacy INLINE behavior on an unsupported warehouse, remove `WithCloudFetch(false)` / `useCloudFetch=false` and keep only the raw session parameter; that legacy mode has a result-size limit and does not guarantee complete large results. Configurations using only the raw parameter retain their existing behavior. + Every kernel configuration using `WithCloudFetch(false)` / `useCloudFetch=false` now requires a warehouse with paged inline support, including configurations using only that option or combining it with the previously documented `cloudfetch_enabled=false`. On an unsupported warehouse, removing the standard disable option allows storage downloads again. To retain legacy INLINE delivery where supported, remove the standard disable option and keep only `cloudfetch_enabled=false`; that legacy mode has a result-size limit and does not guarantee complete large results. Configurations using only the raw parameter retain their existing behavior. ## v1.19.0 (2026-11-04) - Upgrade the SQL kernel bindings to v1.4.0. From 1c5bbb4bdf08d82a231fac529542e154ed1fc035 Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 22:01:10 +0000 Subject: [PATCH 16/21] fix(kernel): delegate CloudFetch policy to native client configuration Signed-off-by: Aakash Saravanan --- CHANGELOG.md | 1 - KERNEL_REV | 2 +- connector_reyden_test.go | 3 +- internal/backend/kernel/backend.go | 14 ++++ internal/backend/kernel/config.go | 3 + kernel_config.go | 22 +----- kernel_config_test.go | 117 ++++------------------------- 7 files changed, 36 insertions(+), 126 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08fd0dac..dfa54899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,6 @@ ## Unreleased - **Behavior change:** Honor `WithCloudFetch(false)` / `useCloudFetch=false` on the kernel backend, taking precedence over raw `can_cloud_download` and `cloudfetch_enabled` session parameters. Complete results use paged inline delivery without storage downloads. Servers without paged inline support return a configuration error at session creation or statement execution; the driver does not fall back to storage downloads. This also applies when a connection automatically switches to the kernel backend after a protocol rejection. - Every kernel configuration using `WithCloudFetch(false)` / `useCloudFetch=false` now requires a warehouse with paged inline support, including configurations using only that option or combining it with the previously documented `cloudfetch_enabled=false`. On an unsupported warehouse, removing the standard disable option allows storage downloads again. To retain legacy INLINE delivery where supported, remove the standard disable option and keep only `cloudfetch_enabled=false`; that legacy mode has a result-size limit and does not guarantee complete large results. Configurations using only the raw parameter retain their existing behavior. ## v1.19.0 (2026-11-04) - Upgrade the SQL kernel bindings to v1.4.0. diff --git a/KERNEL_REV b/KERNEL_REV index d025be44..de1b52ca 100644 --- a/KERNEL_REV +++ b/KERNEL_REV @@ -1 +1 @@ -6f4b6d607a61bdde61dcda2cf82bc8e80fd32cb9 +0b5d0edfed32c0745d5abc2468fc3070e2eb2a17 diff --git a/connector_reyden_test.go b/connector_reyden_test.go index 630d0d6b..858d8ca3 100644 --- a/connector_reyden_test.go +++ b/connector_reyden_test.go @@ -196,7 +196,8 @@ func TestReydenReactiveRecovery(t *testing.T) { func(ctx context.Context, cfg *config.Config) (backend.Backend, error) { require.False(t, cfg.UseCloudFetch) kc := buildKernelConfig(cfg, kernel.Auth{Mode: kernel.AuthPAT, Token: "test-token"}) - require.Equal(t, "false", kc.SessionConf[kernelCloudDownloadConfKey]) + require.NotNil(t, kc.CloudFetchEnabled) + require.False(t, *kc.CloudFetchEnabled) return kernelBackend, nil }, ) diff --git a/internal/backend/kernel/backend.go b/internal/backend/kernel/backend.go index f8e6ebb7..0cfbb2ed 100644 --- a/internal/backend/kernel/backend.go +++ b/internal/backend/kernel/backend.go @@ -67,6 +67,7 @@ import ( "context" "errors" "fmt" + "strconv" "strings" "sync/atomic" "time" @@ -297,6 +298,19 @@ func (k *KernelBackend) OpenSession(ctx context.Context) error { } } + if k.cfg.CloudFetchEnabled != nil { + key := newCStr("cloudfetch_enabled") + value := newCStr(strconv.FormatBool(*k.cfg.CloudFetchEnabled)) + errSet := call(func() C.KernelStatusCode { + return C.kernel_session_config_set_client_conf(cfg, key.c, value.c) + }) + key.free() + value.free() + if errSet != nil { + return fmt.Errorf("kernel: set CloudFetch option: %w", toConnError(errSet)) + } + } + // Log the resolved retry policy + CloudFetch chunk cap before connecting, so if a // customer reports a hung connect or a large-result OOM, on-call can see from the // debug log what was actually applied (these are otherwise silent — forwarded to diff --git a/internal/backend/kernel/config.go b/internal/backend/kernel/config.go index 5a68ce0d..c3f97ed8 100644 --- a/internal/backend/kernel/config.go +++ b/internal/backend/kernel/config.go @@ -44,6 +44,9 @@ type Config struct { // Thrift backend forwards (STATEMENT_TIMEOUT, QUERY_TAGS, TIMEZONE, …). SessionConf map[string]string + // Nil preserves the kernel default and any raw session configuration. + CloudFetchEnabled *bool + // TLSSkipVerify accepts any server cert (maps the driver's // WithSkipTLSHostVerify / TLSConfig.InsecureSkipVerify). crypto/tls's // InsecureSkipVerify disables both chain validation and the hostname check, diff --git a/kernel_config.go b/kernel_config.go index c8c55316..76f70a33 100644 --- a/kernel_config.go +++ b/kernel_config.go @@ -6,8 +6,6 @@ import ( "fmt" "net/url" "strconv" - "strings" - "sync" "time" "github.com/databricks/databricks-sql-go/auth/noop" @@ -16,7 +14,6 @@ import ( "github.com/databricks/databricks-sql-go/internal/backend/kernel" "github.com/databricks/databricks-sql-go/internal/client" "github.com/databricks/databricks-sql-go/internal/config" - "github.com/databricks/databricks-sql-go/logger" "github.com/databricks/databricks-sql-go/telemetry" ) @@ -35,11 +32,6 @@ import ( // resolveKernelAuth's U2M case. const u2mKernelClientID = "databricks-sql-connector" -const kernelCloudDownloadConfKey = "can_cloud_download" -const kernelCloudFetchEnabledConfKey = "cloudfetch_enabled" - -var kernelCloudFetchOverrideWarnOnce sync.Once - func validateClientQueryTimeout(timeout *time.Duration) error { if timeout == nil { return nil @@ -189,18 +181,8 @@ func buildKernelConfig(cfg *config.Config, kauth kernel.Auth) kernel.Config { EnableGeoSpatialSupport: false, } if !cfg.UseCloudFetch { - // Paged inline delivery avoids the legacy INLINE result-size limit. - for key, value := range kc.SessionConf { - if strings.EqualFold(key, kernelCloudDownloadConfKey) || strings.EqualFold(key, kernelCloudFetchEnabledConfKey) { - if strings.EqualFold(key, kernelCloudFetchEnabledConfKey) || !strings.EqualFold(value, "false") { - kernelCloudFetchOverrideWarnOnce.Do(func() { - logger.Warn().Msg("WithCloudFetch(false) overrides raw can_cloud_download and cloudfetch_enabled session parameters for complete inline results") - }) - } - delete(kc.SessionConf, key) - } - } - kc.SessionConf[kernelCloudDownloadConfKey] = "false" + enabled := false + kc.CloudFetchEnabled = &enabled } if cfg.ClientQueryTimeout != nil { timeout := *cfg.ClientQueryTimeout diff --git a/kernel_config_test.go b/kernel_config_test.go index 62c422e9..e7a44b9b 100644 --- a/kernel_config_test.go +++ b/kernel_config_test.go @@ -1,14 +1,11 @@ package dbsql import ( - "bytes" "crypto/tls" "errors" + "fmt" "net/http" - "os" "reflect" - "strings" - "sync" "testing" "time" @@ -18,65 +15,8 @@ import ( "github.com/databricks/databricks-sql-go/internal/backend/kernel" "github.com/databricks/databricks-sql-go/internal/client" "github.com/databricks/databricks-sql-go/internal/config" - "github.com/databricks/databricks-sql-go/logger" ) -func TestBuildKernelConfigCloudFetchOverrideWarning(t *testing.T) { - previousLevel := logger.Logger.GetLevel() - t.Cleanup(func() { - logger.SetLogOutput(os.Stderr) - logger.Logger.Logger = logger.Logger.Level(previousLevel) - kernelCloudFetchOverrideWarnOnce = sync.Once{} - }) - if err := logger.SetLogLevel("warn"); err != nil { - t.Fatal(err) - } - - for _, tc := range []struct { - name string - enabled bool - params map[string]string - warn bool - }{ - {name: "no raw configuration"}, - {name: "matching capability", params: map[string]string{"CAN_CLOUD_DOWNLOAD": "FALSE"}}, - {name: "conflicting capability", params: map[string]string{"Can_Cloud_Download": "true"}, warn: true}, - {name: "private value", params: map[string]string{"can_cloud_download": "private-setting-value"}, warn: true}, - {name: "legacy disabled", params: map[string]string{"CLOUDFETCH_ENABLED": "false"}, warn: true}, - {name: "legacy enabled", params: map[string]string{"cloudfetch_enabled": "true"}, warn: true}, - {name: "enabled preserves raw configuration", enabled: true, params: map[string]string{"can_cloud_download": "true", "cloudfetch_enabled": "false"}}, - {name: "unrelated parameter", params: map[string]string{"TIMEZONE": "UTC"}}, - } { - t.Run(tc.name, func(t *testing.T) { - kernelCloudFetchOverrideWarnOnce = sync.Once{} - var output bytes.Buffer - logger.SetLogOutput(&output) - cfg := baseKernelConfig() - cfg.UseCloudFetch = tc.enabled - cfg.SessionParams = tc.params - buildKernelConfig(cfg, kernel.Auth{}) - first := output.String() - wantWarnings := 0 - if tc.warn { - wantWarnings = 1 - } - if got := strings.Count(first, `"level":"warn"`); got != wantWarnings { - t.Fatalf("warning count = %d, want %d: %s", got, wantWarnings, first) - } - if tc.warn && (!strings.Contains(first, "can_cloud_download") || !strings.Contains(first, "cloudfetch_enabled")) { - t.Fatalf("warning does not name both overridden settings: %s", first) - } - if strings.Contains(first, "private-setting-value") { - t.Fatal("warning exposes a raw parameter value") - } - buildKernelConfig(cfg, kernel.Auth{}) - if output.String() != first { - t.Fatal("warning repeated for a second configuration") - } - }) - } -} - // nonPATAuth stands in for any non-PAT, non-OAuth authenticator (token-provider / // external / static) — the kernel backend must reject it. It implements neither // kernel.M2MCredentialsProvider nor kernel.U2MCredentialsProvider. @@ -763,55 +703,26 @@ func TestBuildKernelConfig(t *testing.T) { } }) - for _, key := range []string{"can_cloud_download", "CAN_CLOUD_DOWNLOAD", "Can_Cloud_Download"} { - t.Run("CloudFetch disabled overrides "+key, func(t *testing.T) { + for _, enabled := range []bool{false, true} { + t.Run(fmt.Sprintf("CloudFetch enabled=%v", enabled), func(t *testing.T) { c := baseKernelConfig() - c.UseCloudFetch = false - c.SessionParams = map[string]string{"TIMEZONE": "UTC", key: "true"} + c.UseCloudFetch = enabled + c.SessionParams = map[string]string{"can_cloud_download": "true", "CLOUDFETCH_ENABLED": "true", "TIMEZONE": "UTC"} + original := map[string]string{"can_cloud_download": "true", "CLOUDFETCH_ENABLED": "true", "TIMEZONE": "UTC"} kc := buildKernelConfig(c, kernel.Auth{Mode: kernel.AuthPAT, Token: "dapi-x"}) - if kc.SessionConf[kernelCloudDownloadConfKey] != "false" || kc.SessionConf["TIMEZONE"] != "UTC" || len(kc.SessionConf) != 2 { - t.Fatalf("unexpected session configuration: %v", kc.SessionConf) - } - if c.SessionParams[key] != "true" { - t.Fatal("caller session parameters were mutated") - } - }) - } - - t.Run("CloudFetch enabled keeps the server default", func(t *testing.T) { - c := baseKernelConfig() - c.UseCloudFetch = true - kc := buildKernelConfig(c, kernel.Auth{Mode: kernel.AuthPAT, Token: "dapi-x"}) - if _, present := kc.SessionConf["can_cloud_download"]; present { - t.Fatalf("unexpected CloudFetch override: %v", kc.SessionConf) - } - }) - - for _, key := range []string{"cloudfetch_enabled", "CLOUDFETCH_ENABLED"} { - t.Run("CloudFetch disabled overrides legacy "+key, func(t *testing.T) { - c := baseKernelConfig() - c.UseCloudFetch = false - c.SessionParams = map[string]string{key: "false", "TIMEZONE": "UTC"} - kc := buildKernelConfig(c, kernel.Auth{Mode: kernel.AuthPAT, Token: "dapi-x"}) - if kc.SessionConf[kernelCloudDownloadConfKey] != "false" || kc.SessionConf["TIMEZONE"] != "UTC" || len(kc.SessionConf) != 2 { - t.Fatalf("unexpected session configuration: %v", kc.SessionConf) + if enabled { + if kc.CloudFetchEnabled != nil { + t.Fatal("enabled mode must keep the kernel default") + } + } else if kc.CloudFetchEnabled == nil || *kc.CloudFetchEnabled { + t.Fatal("disabled mode must forward the client option") } - if c.SessionParams[key] != "false" { - t.Fatal("caller session parameters were mutated") + if !reflect.DeepEqual(kc.SessionConf, original) || !reflect.DeepEqual(c.SessionParams, original) { + t.Fatal("session parameters must be preserved for the kernel to interpret") } }) } - t.Run("CloudFetch enabled preserves explicit session parameters", func(t *testing.T) { - c := baseKernelConfig() - c.UseCloudFetch = true - c.SessionParams = map[string]string{"CAN_CLOUD_DOWNLOAD": "false", "cloudfetch_enabled": "false", "TIMEZONE": "UTC"} - kc := buildKernelConfig(c, kernel.Auth{Mode: kernel.AuthPAT, Token: "dapi-x"}) - if !reflect.DeepEqual(kc.SessionConf, c.SessionParams) { - t.Fatalf("session parameters changed: %v", kc.SessionConf) - } - }) - t.Run("MaxChunksInMemory injected into kernel SessionConf", func(t *testing.T) { c := baseKernelConfig() c.KernelExperimental = &config.KernelExperimentalConfig{MaxChunksInMemory: 4} From 5b3536148525be66ce7d731cc100562f168fcc2d Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 22:21:32 +0000 Subject: [PATCH 17/21] test: verify the standard disable option without a duplicate client setting Signed-off-by: Aakash Saravanan --- CONNECTION_PARAMETERS.md | 19 ++++++++++++------- kernel_cloudfetch_e2e_test.go | 1 - kernel_cloudfetch_test.go | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CONNECTION_PARAMETERS.md b/CONNECTION_PARAMETERS.md index a22d6879..30faba88 100644 --- a/CONNECTION_PARAMETERS.md +++ b/CONNECTION_PARAMETERS.md @@ -113,8 +113,9 @@ Notes: - Boolean-valued keys should use the exact strings `"true"` / `"false"` — the kernel does not pre-validate values and forwards them as-is. -- `WithCloudFetch(false)` requests paged inline delivery on the kernel path by - setting `can_cloud_download=false` for the session. It takes precedence over +- `WithCloudFetch(false)` passes `cloudfetch_enabled=false` through the native + client-conf API. The kernel requests paged inline delivery by setting + `can_cloud_download=false` for the session. Explicit disable takes precedence over case-insensitive `can_cloud_download` and `cloudfetch_enabled` session parameters. The server must support this capability; unsupported servers return a configuration error. @@ -129,7 +130,7 @@ Thrift options where available. | DSN / session-conf key | Dedicated connector option | Thrift | Kernel | Default | Notes | |---|---|:---:|:---:|---|---| -| `cloudfetch_enabled` | *(none; use `WithSessionParams`)* | ⚠️ | ✅ | `true` | Kernel Cloud Fetch toggle; `false` forces inline results. Use `WithCloudFetch` on either backend for the standard connection option. | +| `cloudfetch_enabled` | `WithCloudFetch` | ⚠️ | ✅ | `true` | With the pinned kernel, `false` requests paged inline results without storage downloads. Use `WithCloudFetch` for the standard option on either backend. | | `cloudfetch_link_prefetch_window` | *(none; use `WithSessionParams`)* | ⚠️ | ✅ | `10` | Number of presigned Cloud Fetch links prefetched ahead of the consumer. | | `cloudfetch_max_chunks_in_memory` | `WithKernelMaxChunksInMemory` | ⚠️ | ✅ | `16` | Maximum decompressed Cloud Fetch chunks held in memory. Values above 256 are clamped with a warning, not rejected. | | `inline_max_chunks_in_memory` | *(none; use `WithSessionParams`)* | ⚠️ | ✅ | `4` | Inline-Arrow prefetch window; `1` disables prefetching. | @@ -178,13 +179,17 @@ an internal setting) and non-Arrow values also retain legacy session-location pa | `maxDownloadThreads` | `WithMaxDownloadThreads` | ✅ | ⚠️ | `10` | Concurrent download goroutines (Thrift). Inert on the kernel path. | | | `WithKernelMaxChunksInMemory(n)` | ❌ | ✅ | kernel default (16) | Bounds decompressed Cloud Fetch chunks held in memory — trades large-result throughput for peak memory. | -On the kernel backend, `WithCloudFetch(false)` requests paged inline results using -`can_cloud_download=false`, as the JDBC driver does. This requires a server that +On the kernel backend, `WithCloudFetch(false)` sets the native client setting +`cloudfetch_enabled=false`. The kernel requests paged inline results using +`can_cloud_download=false`. This requires a server that supports paged inline result delivery. Unsupported servers return a configuration error; the driver does not fall back to storage downloads. The standard disable option takes precedence over case-insensitive copies of that session parameter. -The legacy `cloudfetch_enabled=false` client setting selects INLINE Arrow in kernel -1.4.0 and cannot provide this complete large-result behavior. +The raw `cloudfetch_enabled=false` setting has the same result-delivery behavior +with the pinned kernel. Released kernel 1.4.0 uses an older inline path and does +not provide this complete large-result behavior. Connector publication requires +a coordinated native release containing +[databricks-sql-kernel#436](https://github.com/databricks/databricks-sql-kernel/pull/436). ## TLS diff --git a/kernel_cloudfetch_e2e_test.go b/kernel_cloudfetch_e2e_test.go index 687ff9ad..924181f5 100644 --- a/kernel_cloudfetch_e2e_test.go +++ b/kernel_cloudfetch_e2e_test.go @@ -60,7 +60,6 @@ func TestE2EKernelCloudFetchDisabledLargeResults(t *testing.T) { connector, err := NewConnector( WithServerHostname(host), WithHTTPPath(httpPath), WithAccessToken(token), WithUseKernel(true), WithCloudFetch(false), - WithSessionParams(map[string]string{"cloudfetch_enabled": "false"}), WithKernelProxy(KernelProxy{URL: proxy.URL}), WithRetries(-1, time.Millisecond, time.Millisecond), ) diff --git a/kernel_cloudfetch_test.go b/kernel_cloudfetch_test.go index 0e29c644..c728b88d 100644 --- a/kernel_cloudfetch_test.go +++ b/kernel_cloudfetch_test.go @@ -74,7 +74,7 @@ func testKernelCloudFetchDisabledUnsupportedServer(t *testing.T, automaticRecove dbConnector, err := NewConnector( WithServerHostname(server.URL), WithHTTPPath("/sql/1.0/warehouses/test"), WithAccessToken("test-token"), WithUseKernel(true), WithCloudFetch(false), - WithSessionParams(map[string]string{"cloudfetch_enabled": "false", "CAN_CLOUD_DOWNLOAD": "true"}), + WithSessionParams(map[string]string{"CAN_CLOUD_DOWNLOAD": "true"}), WithSkipTLSHostVerify(), WithRetries(-1, time.Millisecond, time.Millisecond), ) require.NoError(t, err) From b4c9ba03c9d8a79609c933c2058e6b0ce9cd8744 Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 22:33:09 +0000 Subject: [PATCH 18/21] fix(logging): show the forwarded CloudFetch option before session open Signed-off-by: Aakash Saravanan --- internal/backend/kernel/backend.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/backend/kernel/backend.go b/internal/backend/kernel/backend.go index 0cfbb2ed..1e1b3173 100644 --- a/internal/backend/kernel/backend.go +++ b/internal/backend/kernel/backend.go @@ -315,8 +315,12 @@ func (k *KernelBackend) OpenSession(ctx context.Context) error { // customer reports a hung connect or a large-result OOM, on-call can see from the // debug log what was actually applied (these are otherwise silent — forwarded to // the kernel with no observable trace). Kept at Debug and cheap to format. - klogCtx(ctx, "OpenSession resolved: retry=%s cloudfetchMaxChunksInMemory=%s", - describeRetry(k.cfg.Retry), k.cfg.SessionConf[kernelMaxChunksInMemoryConfKey]) + cloudFetchEnabled := "kernel-default" + if k.cfg.CloudFetchEnabled != nil { + cloudFetchEnabled = strconv.FormatBool(*k.cfg.CloudFetchEnabled) + } + klogCtx(ctx, "OpenSession resolved: retry=%s cloudfetchMaxChunksInMemory=%s cloudFetchEnabled=%s", + describeRetry(k.cfg.Retry), k.cfg.SessionConf[kernelMaxChunksInMemoryConfKey], cloudFetchEnabled) // kernel_session_open takes ownership of cfg here. Its documented C-ABI // contract (databricks_kernel.h: "CONSUMES config on both success and failure From 52b6a88c204cdc285d58cac0f8b81c5e030418b8 Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 22:40:46 +0000 Subject: [PATCH 19/21] Clarify CloudFetch option logging and normalize proxy authority Signed-off-by: Aakash Saravanan --- internal/backend/kernel/backend.go | 8 ++++---- kernel_cloudfetch_e2e_test.go | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/internal/backend/kernel/backend.go b/internal/backend/kernel/backend.go index 1e1b3173..0c2591cd 100644 --- a/internal/backend/kernel/backend.go +++ b/internal/backend/kernel/backend.go @@ -315,12 +315,12 @@ func (k *KernelBackend) OpenSession(ctx context.Context) error { // customer reports a hung connect or a large-result OOM, on-call can see from the // debug log what was actually applied (these are otherwise silent — forwarded to // the kernel with no observable trace). Kept at Debug and cheap to format. - cloudFetchEnabled := "kernel-default" + cloudFetchOption := "unset" if k.cfg.CloudFetchEnabled != nil { - cloudFetchEnabled = strconv.FormatBool(*k.cfg.CloudFetchEnabled) + cloudFetchOption = strconv.FormatBool(*k.cfg.CloudFetchEnabled) } - klogCtx(ctx, "OpenSession resolved: retry=%s cloudfetchMaxChunksInMemory=%s cloudFetchEnabled=%s", - describeRetry(k.cfg.Retry), k.cfg.SessionConf[kernelMaxChunksInMemoryConfKey], cloudFetchEnabled) + klogCtx(ctx, "OpenSession resolved: retry=%s cloudfetchMaxChunksInMemory=%s cloudFetchOption=%s", + describeRetry(k.cfg.Retry), k.cfg.SessionConf[kernelMaxChunksInMemoryConfKey], cloudFetchOption) // kernel_session_open takes ownership of cfg here. Its documented C-ABI // contract (databricks_kernel.h: "CONSUMES config on both success and failure diff --git a/kernel_cloudfetch_e2e_test.go b/kernel_cloudfetch_e2e_test.go index 924181f5..09866707 100644 --- a/kernel_cloudfetch_e2e_test.go +++ b/kernel_cloudfetch_e2e_test.go @@ -13,6 +13,7 @@ import ( "net/http" "net/http/httptest" "strconv" + "strings" "sync/atomic" "testing" "time" @@ -25,9 +26,11 @@ func TestE2EKernelCloudFetchDisabledLargeResults(t *testing.T) { t.Skip("skipping large inline result in -short mode") } host, httpPath, token := pecoTestingCreds(t) + _, workspaceHost := parseHostName(host) + workspaceAuthority := net.JoinHostPort(workspaceHost, "443") var workspaceConnections, blockedConnections atomic.Int64 proxy := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.Method != http.MethodConnect || r.Host != net.JoinHostPort(host, "443") { + if r.Method != http.MethodConnect || !strings.EqualFold(r.Host, workspaceAuthority) { blockedConnections.Add(1) http.Error(w, "Only the SQL workspace is reachable", http.StatusForbidden) return From a50d75af2e4884f4c31b364c172cb07a723e480d Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Wed, 11 Nov 2026 22:47:43 +0000 Subject: [PATCH 20/21] Keep native option errors and connection docs consistent Signed-off-by: Aakash Saravanan --- CONNECTION_PARAMETERS.md | 5 +---- internal/backend/kernel/backend.go | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CONNECTION_PARAMETERS.md b/CONNECTION_PARAMETERS.md index 30faba88..27df665f 100644 --- a/CONNECTION_PARAMETERS.md +++ b/CONNECTION_PARAMETERS.md @@ -186,10 +186,7 @@ supports paged inline result delivery. Unsupported servers return a configuratio error; the driver does not fall back to storage downloads. The standard disable option takes precedence over case-insensitive copies of that session parameter. The raw `cloudfetch_enabled=false` setting has the same result-delivery behavior -with the pinned kernel. Released kernel 1.4.0 uses an older inline path and does -not provide this complete large-result behavior. Connector publication requires -a coordinated native release containing -[databricks-sql-kernel#436](https://github.com/databricks/databricks-sql-kernel/pull/436). +with the native kernel required by this connector. ## TLS diff --git a/internal/backend/kernel/backend.go b/internal/backend/kernel/backend.go index 0c2591cd..d8e20d08 100644 --- a/internal/backend/kernel/backend.go +++ b/internal/backend/kernel/backend.go @@ -307,7 +307,7 @@ func (k *KernelBackend) OpenSession(ctx context.Context) error { key.free() value.free() if errSet != nil { - return fmt.Errorf("kernel: set CloudFetch option: %w", toConnError(errSet)) + return fmt.Errorf("kernel: set_client_conf[cloudfetch_enabled]: %w", toConnError(errSet)) } } From b08ba0c8e8540179800ae93323d10b5b2eb4f48e Mon Sep 17 00:00:00 2001 From: Aakash Saravanan Date: Thu, 12 Nov 2026 01:59:00 +0000 Subject: [PATCH 21/21] docs: remove CloudFetch release and validation process notes Signed-off-by: Aakash Saravanan --- CHANGELOG.md | 2 +- CONNECTION_PARAMETERS.md | 22 ++++++---------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfa54899..c266790e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Release History ## Unreleased -- **Behavior change:** Honor `WithCloudFetch(false)` / `useCloudFetch=false` on the kernel backend, taking precedence over raw `can_cloud_download` and `cloudfetch_enabled` session parameters. Complete results use paged inline delivery without storage downloads. Servers without paged inline support return a configuration error at session creation or statement execution; the driver does not fall back to storage downloads. This also applies when a connection automatically switches to the kernel backend after a protocol rejection. +- Honor `WithCloudFetch(false)` / `useCloudFetch=false` on the kernel backend to fetch complete results without cloud-storage downloads. The option overrides conflicting session configuration and remains effective after automatic backend recovery. Servers without paged inline support return a configuration error; the driver does not fall back to storage downloads. ## v1.19.0 (2026-11-04) - Upgrade the SQL kernel bindings to v1.4.0. diff --git a/CONNECTION_PARAMETERS.md b/CONNECTION_PARAMETERS.md index 27df665f..ee0a37b6 100644 --- a/CONNECTION_PARAMETERS.md +++ b/CONNECTION_PARAMETERS.md @@ -113,12 +113,11 @@ Notes: - Boolean-valued keys should use the exact strings `"true"` / `"false"` — the kernel does not pre-validate values and forwards them as-is. -- `WithCloudFetch(false)` passes `cloudfetch_enabled=false` through the native - client-conf API. The kernel requests paged inline delivery by setting - `can_cloud_download=false` for the session. Explicit disable takes precedence over - case-insensitive `can_cloud_download` and `cloudfetch_enabled` session parameters. - The server must support - this capability; unsupported servers return a configuration error. +- `WithCloudFetch(false)` fetches complete results through the SQL connection + without cloud-storage downloads. On the kernel backend, this option takes + precedence over conflicting session parameters. Servers without paged inline + support return a configuration error at session creation or statement execution; + the driver does not fall back to storage downloads. ### Kernel client-result confs @@ -130,7 +129,7 @@ Thrift options where available. | DSN / session-conf key | Dedicated connector option | Thrift | Kernel | Default | Notes | |---|---|:---:|:---:|---|---| -| `cloudfetch_enabled` | `WithCloudFetch` | ⚠️ | ✅ | `true` | With the pinned kernel, `false` requests paged inline results without storage downloads. Use `WithCloudFetch` for the standard option on either backend. | +| `cloudfetch_enabled` | `WithCloudFetch` | ⚠️ | ✅ | `true` | Set `false` to fetch complete results without cloud-storage downloads. Use `WithCloudFetch` for the standard option on either backend. | | `cloudfetch_link_prefetch_window` | *(none; use `WithSessionParams`)* | ⚠️ | ✅ | `10` | Number of presigned Cloud Fetch links prefetched ahead of the consumer. | | `cloudfetch_max_chunks_in_memory` | `WithKernelMaxChunksInMemory` | ⚠️ | ✅ | `16` | Maximum decompressed Cloud Fetch chunks held in memory. Values above 256 are clamped with a warning, not rejected. | | `inline_max_chunks_in_memory` | *(none; use `WithSessionParams`)* | ⚠️ | ✅ | `4` | Inline-Arrow prefetch window; `1` disables prefetching. | @@ -179,15 +178,6 @@ an internal setting) and non-Arrow values also retain legacy session-location pa | `maxDownloadThreads` | `WithMaxDownloadThreads` | ✅ | ⚠️ | `10` | Concurrent download goroutines (Thrift). Inert on the kernel path. | | | `WithKernelMaxChunksInMemory(n)` | ❌ | ✅ | kernel default (16) | Bounds decompressed Cloud Fetch chunks held in memory — trades large-result throughput for peak memory. | -On the kernel backend, `WithCloudFetch(false)` sets the native client setting -`cloudfetch_enabled=false`. The kernel requests paged inline results using -`can_cloud_download=false`. This requires a server that -supports paged inline result delivery. Unsupported servers return a configuration -error; the driver does not fall back to storage downloads. The standard disable -option takes precedence over case-insensitive copies of that session parameter. -The raw `cloudfetch_enabled=false` setting has the same result-delivery behavior -with the native kernel required by this connector. - ## TLS | Connector option | Thrift | Kernel | Notes |