Description
User @cloudcell on duckdb discord raised this issue:
Hello, I am using dbeaver to view the contents of the database that has a BLOB field; however, instead of data I see this:
DuckDBBlobResult{buffer=java.nio.DirectByteBuffer[pos=0 lim=2 cap=2]}
Does anyone have any ideas what's going wrong?
I am able to reproduce this with GA duckdb JDBC.
I checked a similar example with MySQL and found DBeaver to return the blob data as string.
In other words, it appears to have to do with the DuckDB driver, not DBeaver software.
I tried to figure out how DBeaver displays the Blobs but have not been able to analyze their code.
It's probably there somewhere but I can't find it.
I have looked into the DuckDB JDBC driver and I have found some pieces of code that might explain the behavior.
If DBeaver uses the JDBC getString(column)
method, (https://github.com/duckdb/duckdb-java/blob/main/src/main/java/org/duckdb/DuckDBResultSet.java#L206), then the DuckDB driver ends up calling getObject()
and then applies toString()
to the object value.
The resultset getObject()
is implemented by calling getObject()
on the DuckDBVector
(https://github.com/duckdb/duckdb-java/blob/main/src/main/java/org/duckdb/DuckDBVector.java#L112), and for Blob data type this will instantiate DuckDBResultSet.DuckDBBlobResult
(https://github.com/duckdb/duckdb-java/blob/main/src/main/java/org/duckdb/DuckDBVector.java#L276), which overrides toString()
to return something that looks a lot like what we see in the DBeaver interface (https://github.com/duckdb/duckdb-java/blob/main/src/main/java/org/duckdb/DuckDBResultSet.java#L492)
(To be clear, I am not saying this is the cause, I'm just saying that this would explain it if we assume DBeaver calls getString on the JDBC resultset for the Blob column)
I think it is not entirely clear whether this is a bug or not.
It is of course mighty inconvenient for DBeaver users.