duckdb / duckdb/duckdb-java

Wrong WKB produced by jdbc driver when reading geometry type

Open
#486 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
127
Forks
80
Avg merge
13h 49m
Merged PRs (30d)
48

Description

Try this:

```java
try (Statement s = connection.createStatement()) {
s.executeUpdate("install spatial");
s.executeUpdate("load spatial");

try (ResultSet rs = s.executeQuery("select cast('point (1 1)' as geometry)")) {
rs.next();
println(HexFormat.of().formatHex(rs.getBytes(1)));
}
}
```

This prints:

```
00000000000000000000000001000000000000000000f03f000000000000f03f
```

Which is an invalid WKB representation of `point(1 1)`. The correct representation is:

```
0101000000000000000000f03f000000000000f03f
```

This can be validated with this query:

```sql
select st_ashexwkb(cast ('POINT(1 1)' as geometry));
```

Or also with PostgreSQL:

```sql
select encode(st_asbinary(cast('point (1 1)' as geometry)), 'hex')`
```

I'm not sure if this is a duckdb_jdbc problem or a duckdb problem. Feel free to move the issue if it's not a JDBC problem.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.