Wrong WKB produced by jdbc driver when reading geometry type

Open
#486 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java, sql
Domain
database

Research direction

Reproduce the Java JDBC example in the issue and compare the returned bytes with st_ashexwkb and PostgreSQL's st_asbinary output. Trace whether the invalid WKB is produced by the JDBC driver or DuckDB, then confirm that the returned geometry bytes match the valid point representation.

Written by the indexing model from the issue text.

Description

Try this:

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:

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

Or also with PostgreSQL:

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.

Dominant language
C++
Stars
127
Forks
80
Avg merge
13h 41m
Merged PRs (30d)
44

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from duckdb/duckdb-java

All issues in duckdb/duckdb-java

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.