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

Using WHERE uuid_field= uuid '....' on a table with a UUID field as partition key doesn't work #10799

Closed
findinpath opened this issue Jan 25, 2022 · 1 comment · Fixed by #10856
Labels
bug Something isn't working

Comments

@findinpath
Copy link
Contributor

findinpath commented Jan 25, 2022

For reproducing the issue is enough to select from a table having uuid as the partition key
Tested with Trino 370-SNAPSHOT

trino> SELECT bv.my_id, bv.tag_key, bv.value, bv.some_id
    -> FROM cassandra.some_data.by_value AS bv
    -> WHERE bv.my_id = UUID '71d32975-d8df-4906-a1bf-4fa493528532'
    ->   AND bv.tag_key = 'club'
    -> LIMIT 5;
Query 20220125_191354_00012_sypkc failed: Invalid UUID string: q�)u��I��O��R�2

io.trino.plugin.cassandra.CassandraType#getJavaValue

In case of dealing with UUID there is an attempt to take the string representation of the value:

return java.util.UUID.fromString(((Slice) trinoNativeValue).toStringUtf8()); 

However, in case of dealing with partition filter in trino-spi (see Range class) the UUID value is encoded with UuidType.

Probably the methods:

  • io.trino.plugin.cassandra.CassandraSession#addWhereInClauses
  • io.trino.plugin.cassandra.CassandraSession#addWhereClause

need to be changed not to rely on io.trino.plugin.cassandra.CassandraType#getJavaValue
, but on something that uses for UUIDs

return java.util.UUID.fromString((String)UuidType.UUID.getObjectValue(connectorSession, Utils.nativeValueToBlock(UuidType.UUID, trinoNativeValue), 0));

The first parameter from getObjectValue is a ConnectorSession argument.
I’m not sure whether the above mentioned solution is the way to go, but if it is adding the depedency of ConnectorSession on the CassandraSession
Related method io.trino.plugin.cassandra.CassandraPartitionManager#getPartitionKeysList

@findinpath findinpath added the bug Something isn't working label Jan 25, 2022
@ebyhr
Copy link
Member

ebyhr commented Jan 26, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants