Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBeaver shows Blob as "DuckDBBlobResult{buffer=java.nio.DirectByteBuffer[pos=0 lim=2 cap=2]}" #70

Open
rpbouman opened this issue Aug 23, 2024 · 2 comments

Comments

@rpbouman
Copy link
Contributor

rpbouman commented Aug 23, 2024

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?

image

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.

@EastLord
Copy link

dbeaver/dbeaver#35328
The DBeaver does not support DuckDB's BLOB.

@cloudcell
Copy link

cloudcell commented Aug 26, 2024

The previous version of DBeaver did support BLOBs, however the behavior was somewhat problematic. For example, it would not show you the blob unless you clicked on the cell within the record. Also, the first record of the table would show different values when being repeatedly updated. I am currently using SQLTools for VSCode, which shows the beginning of every BLOB record, which is totally fine. Perhaps someone can adapt some code used in SQLTools.

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

No branches or pull requests

3 participants