Skip to content

Conversation

staticlibs
Copy link
Collaborator

This change adjusts the ResultSet#getString() behaviour for columns with composite types like STRUCT or LIST and also for extension types. This method now delegates the cast to the native cast to VARCHAR. When the extension (e.g. spatial) registers a cast for its own types to VARCHAR - this cast now will be triggered.

In many cases, like MAPs, the resulting representation is the same. But in some cases, like spatial's GEOMETRY the resulting string now can be correctly deserialized into its textual representation:

POINT (41.1 42.2)

instead of opaque (and useless one):

DuckDBBlobResult{buffer=java.nio.HeapByteBuffer[pos=0 lim=32 cap=32]}

Fixes: #298

This change adjusts the `ResultSet#getString()` behaviour for columns
with composite types like `STRUCT` or `LIST` and also for extension
types. This method now delegates the cast to the native cast to
`VARCHAR`. When the extension (e.g. `spatial`) registers a cast for its
own types to `VARCHAR` - this cast now will be triggered.

In many cases, like `MAP`s, the resulting representation is the same.
But in some cases, like `spatial`'s `GEOMETRY` the resulting string now
can be correctly deserialized into its textual representation:

```
POINT (41.1 42.2)
```

instead of opaque (and useless one):

```
DuckDBBlobResult{buffer=java.nio.HeapByteBuffer[pos=0 lim=32 cap=32]}
```

Fixes: duckdb#298
@staticlibs staticlibs mentioned this pull request Jul 23, 2025
@staticlibs staticlibs merged commit 543e5ac into duckdb:main Sep 8, 2025
9 checks passed
@staticlibs staticlibs deleted the native_string_cast branch September 8, 2025 16:03
staticlibs added a commit to staticlibs/duckdb-java that referenced this pull request Sep 15, 2025
This is a backport of the PR duckdb#320 to `v1.4-andium` stable branch.

This change adjusts the `ResultSet#getString()` behaviour for columns
with composite types like `STRUCT` or `LIST` and also for extension
types. This method now delegates the cast to the native cast to
`VARCHAR`. When the extension (e.g. `spatial`) registers a cast for its
own types to `VARCHAR` - this cast now will be triggered.

In many cases, like `MAP`s, the resulting representation is the same.
But in some cases, like `spatial`'s `GEOMETRY` the resulting string now
can be correctly deserialized into its textual representation:

```
POINT (41.1 42.2)
```

instead of opaque (and useless one):

```
DuckDBBlobResult{buffer=java.nio.HeapByteBuffer[pos=0 lim=32 cap=32]}
```

Fixes: duckdb#298
staticlibs added a commit that referenced this pull request Sep 15, 2025
This is a backport of the PR #320 to `v1.4-andium` stable branch.

This change adjusts the `ResultSet#getString()` behaviour for columns
with composite types like `STRUCT` or `LIST` and also for extension
types. This method now delegates the cast to the native cast to
`VARCHAR`. When the extension (e.g. `spatial`) registers a cast for its
own types to `VARCHAR` - this cast now will be triggered.

In many cases, like `MAP`s, the resulting representation is the same.
But in some cases, like `spatial`'s `GEOMETRY` the resulting string now
can be correctly deserialized into its textual representation:

```
POINT (41.1 42.2)
```

instead of opaque (and useless one):

```
DuckDBBlobResult{buffer=java.nio.HeapByteBuffer[pos=0 lim=32 cap=32]}
```

Fixes: #298
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DuckDB-1.3.1.0] Geometry Functions return now DuckDBBlobResult instead of Text
1 participant