From 120babfab8d0b57cd2dc48760767740223c64b65 Mon Sep 17 00:00:00 2001 From: Madhavendra Rathore Date: Sun, 31 May 2026 13:38:17 +0000 Subject: [PATCH] feat(napi): expose intervalsAsString + complexTypesAsJson on openSession MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Surface the kernel's ResultConfig.intervals_as_string and complex_types_as_json knobs on the napi ConnectionOptions, threaded onto the SessionBuilder via `builder.result(ResultConfig)` (mirrors the pyo3 Session.__new__ surface). Omitted ⇒ kernel default (native Arrow month_interval / duration[us] and native nested types). Motivation: the NodeJS Thrift driver surfaces INTERVAL columns as strings, so the SEA driver needs intervals_as_string=true for byte-compatible result parity (verified via the node comparator — interval columns then match Thrift in both type code and value). complex_types_as_json is exposed alongside for completeness; the SEA driver leaves it at the native-Arrow default (which already decodes identically to Thrift). Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore --- napi/src/database.rs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/napi/src/database.rs b/napi/src/database.rs index ede8b051..02135172 100644 --- a/napi/src/database.rs +++ b/napi/src/database.rs @@ -28,7 +28,9 @@ use std::collections::HashMap; use std::sync::Arc; use tokio::sync::Mutex; -use databricks_sql_kernel::{AuthConfig, DefaultOpts, Error as KernelError, HttpConfig, Session}; +use databricks_sql_kernel::{ + AuthConfig, DefaultOpts, Error as KernelError, HttpConfig, ResultConfig, Session, +}; /// NodeJS-driver-appropriate default for `pool_max_idle_per_host`. /// @@ -146,6 +148,19 @@ pub struct ConnectionOptions { /// Napi-rs serialises `u32` as JS `number`; values up to /// `2^32 - 1` round-trip safely (any reasonable pool size fits). pub max_connections: Option, + /// Render `INTERVAL` / `DURATION` result columns as strings + /// (`ResultConfig.intervals_as_string`). The kernel default is + /// native Arrow `month_interval` / `duration[us]` types; the NodeJS + /// Thrift driver surfaces intervals as strings, so the SEA driver + /// sets this `true` for byte-compatible parity. Omitted ⇒ kernel + /// default (native Arrow interval types). + pub intervals_as_string: Option, + /// Render complex (`ARRAY` / `MAP` / `STRUCT` / `VARIANT`) result + /// columns as JSON strings (`ResultConfig.complex_types_as_json`) + /// instead of native Arrow nested types. Omitted ⇒ kernel default + /// (native Arrow nested types, which the NodeJS Arrow decoder + /// already renders identically to the Thrift path). + pub complex_types_as_json: Option, } /// Require a non-empty `Option` field for a given auth mode, @@ -238,6 +253,19 @@ pub async fn open_session(options: ConnectionOptions) -> napi::Result