Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions CONNECTION_PARAMETERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,28 +185,28 @@ Arrow representation of `GEOMETRY` and `GEOGRAPHY` values.

| Value | Arrow representation |
|-------|----------------------|
| `GeospatialResultRepresentation::String` | Arrow `Utf8` containing EWKT (the default). |
| `GeospatialResultRepresentation::Binary` | Arrow `struct<srid: int32 not null, wkb: binary not null>` containing the SRID and little-endian OGC WKB. The WKB itself is not EWKB. |

Reyden returns every geo value as that native struct. The physical attachment
can omit the canonical Arrow tags, while Reyder's structured manifest reports
the logical `GEOMETRY(...)` or `GEOGRAPHY(...)` type and is the source of
truth. The kernel reconciles the attachment with that logical schema: binary
mode attaches `geometry=true` or `geography=true` and the type-level `srid`
(`-1` for `ANY`) to the `wkb` field, and string mode recursively converts the
WKB to EWKT. Every row's sibling `srid` carries the actual value. Nested values
in arrays, maps, and structs and null outer structs are preserved.

On legacy SEA paths that already return geospatial columns as Arrow `Utf8`,
string mode preserves those values. Binary mode requires Reyden's native
`struct<srid,wkb>` attachment and returns an error when only text is available;
the kernel does not parse server-rendered text back into WKB.
| `GeospatialResultRepresentation::String` | Arrow `Utf8` containing WKT / EWKT. |
| `GeospatialResultRepresentation::Binary` | Arrow `struct<srid: int32 not null, wkb: binary not null>` containing the SRID and little-endian OGC WKB. The WKB itself is not EWKB. This is the default. |

Reyden returns every geo value as that native struct; standard DBSQL warehouses
return WKT / EWKT as Arrow `Utf8` or `LargeUtf8`. The structured manifest
reports the logical `GEOMETRY(...)` or `GEOGRAPHY(...)` type and is the source
of truth for either attachment. The kernel normalizes both paths: binary mode
attaches the canonical tags to a Reyden struct or parses standard-warehouse
text into the same tagged SRID+WKB struct, while string mode preserves existing
text or renders a native struct as EWKT. Nested values in arrays, maps, and
structs, per-row SRIDs, and null outer values are preserved.

This is entirely client-side and is never forwarded to SEA. Set it through
the typed kernel or binding API. A `geospatial_as_string` entry placed
the typed kernel or binding API. An `EnableGeoSpatialSupport` entry placed
directly in `session_conf` is not interpreted by the kernel and is forwarded
unchanged; SEA/Reyden does not define that server configuration.

Bindings expose the same default-enabled boolean as Python
`enable_geospatial_support`, Node.js `enableGeoSpatialSupport`, and C
`kernel_session_config_set_enable_geospatial_support`. Enabled returns the
native SRID+WKB Arrow representation; disabled returns WKT / EWKT strings.

The structured manifest type text is authoritative for identifying geo leaves;
the attachment supplies the physical values. The same post-processing step
produces the requested client-facing schema for non-empty and empty results.
Expand Down
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ base64 = "0.22"
hex = "0.4" # Hex encoding (binary param literals, token cache key)
wkb = "0.9.2" # OGC WKB parser for geospatial result rendering
geo-traits = "0.3" # Generic geometry traversal for WKB-to-EWKT rendering
wkt = { version = "0.14", default-features = false } # OGC WKT parser for legacy SEA results

# Date/time handling
chrono = { version = "0.4", features = ["serde"] }
Expand Down
10 changes: 8 additions & 2 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ changes go in their respective binding's NEXT_CHANGELOG.
reconciles attachments that omit the canonical tags without copying child
buffers.
- Added typed client-side `GEOMETRY` / `GEOGRAPHY` result representation
selection. String mode renders the native WKB as EWKT locally; binary mode
retains the tagged Arrow struct. No representation setting is sent to SEA.
selection. The kernel normalizes both standard-warehouse WKT / EWKT and
Reyden's native SRID+WKB struct to the requested representation. No
representation setting is sent to SEA.
- Added the default-enabled
`kernel_session_config_set_enable_geospatial_support` C ABI setting. Enabled
returns native SRID+WKB Arrow results; disabled returns WKT / EWKT strings.
- Add authenticated connector-service feature flags with a bounded,
process-wide workspace cache and kernel-internal typed readers for all six
SAFE types.
Expand All @@ -31,6 +35,8 @@ changes go in their respective binding's NEXT_CHANGELOG.

### Changed

- Native SRID+WKB is now the default geospatial result representation.

- Route function metadata through the Thrift-native metadata path when supported by the server.
- Authenticated SEA requests now use `Accept-Encoding: identity` by default to
avoid gzipping inline LZ4-compressed Arrow results. Response compression can
Expand Down
12 changes: 12 additions & 0 deletions include/databricks_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,18 @@ KernelStatusCode kernel_session_config_set_session_conf(KernelSessionConfig* con
const char* key,
const char* value);

/* Select whether GEOMETRY / GEOGRAPHY results use their native Arrow
* representation. `enabled = true` requests Arrow
* `struct<srid: int32, wkb: binary>` values; `false` requests WKT / EWKT in
* Arrow UTF-8 values. Omitting this setter uses the enabled kernel default.
* The kernel normalizes both standard-warehouse text and Reyden native Arrow
* results locally; this setting is never sent to SEA. A raw
* `EnableGeoSpatialSupport` entry set through
* kernel_session_config_set_session_conf remains server-bound and is forwarded
* unchanged. */
KernelStatusCode kernel_session_config_set_enable_geospatial_support(
KernelSessionConfig* config, bool enabled);

/* Append one HTTP header sent on every request. Call once per header
* (order preserved); `name` and `value` are both required. */
KernelStatusCode kernel_session_config_set_custom_header(KernelSessionConfig* config,
Expand Down
13 changes: 13 additions & 0 deletions napi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions napi/NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ layout, or npm publishing. Pure-kernel changes go in the root

### Added

- Added the default-enabled `ConnectionOptions.enableGeoSpatialSupport` option.
Enabled returns native SRID+WKB Arrow results; disabled returns WKT / EWKT
strings.
- Added `ConnectionOptions.seaResponseCompressionEnabled` to opt back into
HTTP compression for bandwidth-constrained SEA connections.

Expand Down
9 changes: 9 additions & 0 deletions napi/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@ export interface ConnectionOptions {
* `session_confs`. Unknown keys are rejected server-side.
*/
sessionConf?: Record<string, string>
/**
* Select whether `GEOMETRY` / `GEOGRAPHY` results use their native Arrow
* representation. `true` (the default) requests Arrow
* `struct<srid: int32, wkb: binary>` values; `false` requests WKT / EWKT
* in Arrow UTF-8 values. The kernel normalizes both standard-warehouse
* text and Reyden native Arrow results locally and never sends this choice
* to SEA.
*/
enableGeoSpatialSupport?: boolean
Comment thread
cathleeny marked this conversation as resolved.
Resolved
Comment thread
cathleeny marked this conversation as resolved.
Resolved
/**
* Driver name reported in telemetry system configuration. Omitted ⇒
* kernel default.
Expand Down
40 changes: 38 additions & 2 deletions napi/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ use napi::bindgen_prelude::Buffer;
type Buffer = Vec<u8>;

use databricks_sql_kernel::{
AuthConfig, DefaultOpts, DriverSystemConfiguration, Error as KernelError, HttpConfig,
ProxyConfig, ResultConfig, Session, TelemetryConfig, TlsConfig, TokenCacheConfig,
AuthConfig, DefaultOpts, DriverSystemConfiguration, Error as KernelError,
GeospatialResultRepresentation, HttpConfig, ProxyConfig, ResultConfig, Session,
TelemetryConfig, TlsConfig, TokenCacheConfig,
};

/// NodeJS-driver-appropriate default for `pool_max_idle_per_host`.
Expand Down Expand Up @@ -231,6 +232,13 @@ pub struct ConnectionOptions {
/// query-tag presets, …). Forwarded verbatim to SEA
/// `session_confs`. Unknown keys are rejected server-side.
pub session_conf: Option<HashMap<String, String>>,
/// Select whether `GEOMETRY` / `GEOGRAPHY` results use their native Arrow
/// representation. `true` (the default) requests Arrow
/// `struct<srid: int32, wkb: binary>` values; `false` requests WKT / EWKT
Comment thread
cathleeny marked this conversation as resolved.
Resolved
/// in Arrow UTF-8 values. The kernel normalizes both standard-warehouse
/// text and Reyden native Arrow results locally and never sends this choice
/// to SEA.
pub enable_geo_spatial_support: Option<bool>,
Comment thread
cathleeny marked this conversation as resolved.
Resolved
/// Driver name reported in telemetry system configuration. Omitted ⇒
/// kernel default.
pub driver_name: Option<String>,
Expand Down Expand Up @@ -775,6 +783,14 @@ fn build_driver_system_configuration(
})
}

fn geospatial_result_representation(enabled: Option<bool>) -> GeospatialResultRepresentation {
if enabled.unwrap_or(true) {
GeospatialResultRepresentation::Binary
} else {
GeospatialResultRepresentation::String
}
}

/// Open a Databricks SQL session and return an opaque `Connection`
/// wrapping the kernel `Session`. Authentication is selected by
/// `options.auth_mode` (PAT / OAuth M2M / OAuth U2M) — see
Expand Down Expand Up @@ -835,6 +851,9 @@ pub async fn open_session(mut options: ConnectionOptions) -> napi::Result<Connec
if let Some(conf) = options.session_conf {
builder = builder.session_conf(conf);
}
builder = builder.geospatial_result_representation(geospatial_result_representation(
options.enable_geo_spatial_support,
));
// Result-config knobs (interval / complex-type rendering). Merge
// into one `ResultConfig` so the two toggles don't clobber each
// other when both are set. Only wire it when at least one is
Expand Down Expand Up @@ -913,6 +932,7 @@ mod tests {
catalog: None,
schema: None,
session_conf: None,
enable_geo_spatial_support: None,
driver_name: None,
driver_version: None,
runtime_name: None,
Expand Down Expand Up @@ -953,6 +973,22 @@ mod tests {
}
}

#[test]
fn enable_geospatial_support_maps_to_kernel_representation() {
assert_eq!(
geospatial_result_representation(None),
GeospatialResultRepresentation::Binary
);
assert_eq!(
geospatial_result_representation(Some(true)),
GeospatialResultRepresentation::Binary
);
assert_eq!(
geospatial_result_representation(Some(false)),
GeospatialResultRepresentation::String
);
}

/// Assert a `build_auth_config` failure surfaces as a kernel
/// `InvalidArgument` (napi `Status::InvalidArg` + `"code":
/// "InvalidArgument"` in the error envelope) and that the kernel
Expand Down
13 changes: 13 additions & 0 deletions pyo3/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyo3/NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ changes go in the root `NEXT_CHANGELOG.md`.

### Added

- Added the default-enabled `enable_geospatial_support` session argument.
Enabled returns native SRID+WKB Arrow results; disabled returns WKT / EWKT
strings.
- Added `Session(..., sea_response_compression_enabled=...)` to opt back into
HTTP compression for bandwidth-constrained SEA connections.

Expand Down
Loading
Loading