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

Can't insert blob as map value #126

Open
nivekuil opened this issue Sep 18, 2022 · 2 comments
Open

Can't insert blob as map value #126

nivekuil opened this issue Sep 18, 2022 · 2 comments

Comments

@nivekuil
Copy link
Contributor

nivekuil commented Sep 18, 2022

For some reason a byte array can't be serialized if it's in a map. I added a failing test to show this nivekuil@3b49737 which throws an exception Caused by: com.datastax.oss.driver.api.core.type.codec.CodecNotFoundException: Codec not found for requested operation: [BLOB <-> [B]

@nivekuil
Copy link
Contributor Author

same for vector/List, looking into it I found some leads:

apache/cassandra-java-driver#1555
datastax/spark-cassandra-connector#1334

@nivekuil
Copy link
Contributor Author

From the first link, I figured out a workaround

If you are looking for a BLOB codec, the right call is CachingCodecRegistry.codecFor(DataType.BLOB, ByteBuffer.class). Indeed, there is a default BLOB codec registered in the driver that converts BLOB columns to ByteBuffer objects.

But, as explained in the docs, this method does not accept covariant classes. So if you try, say, CachingCodecRegistry.codecFor(DataType.BLOB, HeapByteBuffer.class) – then the method will throw CodecNotFoundException – even if HeapByteBuffer is a subtype of ByteBuffer.

This is probably not the right way to fix it, but this unblocks me for now df69e50

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

1 participant