Skip to content

Commit c96f69e

Browse files
committed
feat: add databricks.arrow.native_geospatial option for Arrow geometry
Expose geospatialAsArrow support (SPARK-54232) as an opt-in ADBC connection option. When set to "true", geometry/geography columns arrive as Struct<srid: Int32, wkb: Binary> instead of EWKT strings. This depends on databricks/databricks-sql-go#328 which adds the WithArrowNativeGeospatial() ConnOption to the underlying Go SQL driver. Usage via adbc_connect (e.g. from DuckDB adbc_scanner): adbc_connect({ 'driver': 'libadbc_driver_databricks.dylib', 'databricks.server_hostname': '...', 'databricks.arrow.native_geospatial': 'true' })
1 parent 4a962cc commit c96f69e

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

go/database.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ type databaseImpl struct {
8080
oauthClientID string
8181
oauthClientSecret string
8282
oauthRefreshToken string
83+
84+
// Arrow serialization options
85+
useArrowNativeGeospatial bool
8386
}
8487

8588
func (d *databaseImpl) resolveConnectionOptions() ([]dbsql.ConnOption, error) {
@@ -148,6 +151,13 @@ func (d *databaseImpl) resolveConnectionOptions() ([]dbsql.ConnOption, error) {
148151
opts = append(opts, dbsql.WithMaxDownloadThreads(d.downloadThreadCount))
149152
}
150153

154+
// Arrow-native geospatial serialization (SPARK-54232).
155+
// When enabled, geometry/geography columns arrive as Struct<srid: Int32, wkb: Binary>
156+
// instead of EWKT strings, enabling native geometry passthrough.
157+
if d.useArrowNativeGeospatial {
158+
opts = append(opts, dbsql.WithArrowNativeGeospatial(true))
159+
}
160+
151161
// TLS/SSL handling
152162
// Configure a custom transport with proper timeout settings when custom
153163
// TLS config is needed. These settings match the defaults from
@@ -320,6 +330,11 @@ func (d *databaseImpl) GetOption(key string) (string, error) {
320330
return d.oauthClientSecret, nil
321331
case OptionOAuthRefreshToken:
322332
return d.oauthRefreshToken, nil
333+
case OptionArrowNativeGeospatial:
334+
if d.useArrowNativeGeospatial {
335+
return adbc.OptionValueEnabled, nil
336+
}
337+
return adbc.OptionValueDisabled, nil
323338
default:
324339
return d.DatabaseImplBase.GetOption(key)
325340
}
@@ -486,6 +501,18 @@ func (d *databaseImpl) SetOption(key, value string) error {
486501
d.oauthClientSecret = value
487502
case OptionOAuthRefreshToken:
488503
d.oauthRefreshToken = value
504+
case OptionArrowNativeGeospatial:
505+
switch value {
506+
case adbc.OptionValueEnabled:
507+
d.useArrowNativeGeospatial = true
508+
case adbc.OptionValueDisabled, "":
509+
d.useArrowNativeGeospatial = false
510+
default:
511+
return adbc.Error{
512+
Code: adbc.StatusInvalidArgument,
513+
Msg: fmt.Sprintf("invalid value for %s: %s (expected 'true' or 'false')", OptionArrowNativeGeospatial, value),
514+
}
515+
}
489516
default:
490517
return d.DatabaseImplBase.SetOption(key, value)
491518
}

go/driver.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ const (
6767
OptionOAuthClientSecret = "databricks.oauth.client_secret"
6868
OptionOAuthRefreshToken = "databricks.oauth.refresh_token"
6969

70+
// Arrow serialization options
71+
OptionArrowNativeGeospatial = "databricks.arrow.native_geospatial"
72+
7073
// Default values
7174
DefaultPort = 443
7275
DefaultSSLMode = "require"

0 commit comments

Comments
 (0)