dbeaver / dbeaver

Free universal database tool and SQL client
https://dbeaver.io
Apache License 2.0
39.27k stars 3.4k forks source link

DBeaver fails to show BLOB data in a table from a DuckDB database #35328

Open cloudcell opened 3 weeks ago

cloudcell commented 3 weeks ago

Description

I am using dbeaver to view the contents of a database with a table that has a BLOB field; however, instead of data I see this: DuckDBBlobResult{buffer=java.nio.DirectByteBuffer[pos=0 lim=2 cap=2]}

DBeaver Version

Community Edition 24.1.5.202408181605

Operating System

xubuntu 22.04 LTS jammy jellyfish

Database and driver

DuckDB 1.0 with accompanying latest jdbc driver 1.0

Steps to reproduce

  1. connect to the database and write a BLOB containing 2 bytes of any random data
  2. close the connection with the database
  3. open the database in dbeaver-ce
  4. view the data in the table
  5. you should see something like this:
    node_id|data                                                                 |
    -------+---------------------------------------------------------------------+
    1      |DuckDBBlobResult{buffer=java.nio.DirectByteBuffer[pos=0 lim=2 cap=2]}|
    2      |DuckDBBlobResult{buffer=java.nio.DirectByteBuffer[pos=0 lim=2 cap=2]}|
    3      |DuckDBBlobResult{buffer=java.nio.DirectByteBuffer[pos=0 lim=2 cap=2]}|
    5      |DuckDBBlobResult{buffer=java.nio.DirectByteBuffer[pos=0 lim=2 cap=2]}|
    6      |DuckDBBlobResult{buffer=java.nio.DirectByteBuffer[pos=0 lim=2 cap=2]}|

Additional context

I also downloaded DBeaver for windows with the same result. However, DataGrip (software by JetBrains) shows the correct contents: image

E1izabeth commented 3 weeks ago

Thank you for bug report!

rpbouman commented 2 weeks ago

Hi all, I tried to find the piece of DBeaver code that extracts the Blob and renders it in the UI but have not been able to find that.

However, I looked into the DuckDB JDBC driver code (https://github.com/duckdb/duckdb-java/issues/70) and as far as I can see, code like:

String str = resultset.getString(column);

Would result in the kind of values reported by @cloudcell. Could you confirm if that is what is happening?

If this is indeed the case, then we at least can explain why we see the current behavior.

If this is a bug in the DuckDB Driver or not, is another matter.

Blobs are meant for storing binary data. There is no metadata that tells how the bytes in the blob should be interpreted. Of course, in java you can instantiate Strings from bytes, but this implies some sort of character encoding which is exactly the kind of metadata we don't have at this level.

I do get that for a tool like DBeaver the challenge is to provide a sensible display in the gui also for a blob result. An approach that I think would be sensible and correct is to show just the raw byte content, possible formatted (on the client side) using hex display, octal, or even ascii - but this would be in the realm of the application (DBeaver), not of the driver.

Calling getString() on the resultset for Blob columns is probably not going to yield reliable output across different drivers.

E1izabeth commented 2 weeks ago

Linked discussion https://github.com/orgs/dbeaver/discussions/35346