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

Correct decoding for Trino UUID partition key value #10856

Merged

Conversation

findinpath
Copy link
Contributor

Fixes #10799

@cla-bot cla-bot bot added the cla-signed label Jan 30, 2022
@findinpath findinpath requested review from hashhar and ebyhr January 30, 2022 23:05
" typetimestamp timestamp, " +
" typeansi ascii, " +
" typeboolean boolean, " +
" typedecimal decimal, " +
Copy link
Contributor Author

@findinpath findinpath Jan 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've skipped (in this initial commit) on purpose adding the typedecimal field to the composed primary key because the test is failing. Apparently in Cassandra 2.2 when comparing 128.0 with 128 there is no match found.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you file an issue and leave as code comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created #10927 and referenced it in the new test.

@@ -237,6 +238,32 @@ public void testCharVarcharComparison()
.hasMessage("unsupported type: char(3)");
}

@Test
public void testAllPartitionKeyTypesPushdownPredicate()
Copy link
Contributor Author

@findinpath findinpath Jan 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestCassandraConnectorTest tests on Cassandra 2.2.
However the code has the following logic

https://github.com/trinodb/trino/blob/master/plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraSession.java#L369-L376

for retrieving the partitions.

Any advice on how could we cover the usecase of dealing with Cassandra 2.2+ ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I understood your question correctly, but the image name 2.2 gets the latest 2.2.x (=2.2.19 today). The comparison (2.2.19 compareTo 2.2 > 0) will return true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the confusion.

I was wondering how do we get to test the else branch.

            log.debug("Using combination of partition values to fetch partitions.");
            rows = queryPartitionKeysLegacyWithMultipleQueries(table, filterPrefixes);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can get the coverage by running tests on Cassandra 2.1. It will require some refactoring of tests though.

@findinpath findinpath requested a review from electrum January 31, 2022 14:53
Copy link
Member

@ebyhr ebyhr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please separate into two commits because other types are unrelates to the bug fix

  1. Correct decoding for Trino UUID partition key value + only UUID test
  2. Add other types to the test

@@ -237,6 +238,32 @@ public void testCharVarcharComparison()
.hasMessage("unsupported type: char(3)");
}

@Test
public void testAllPartitionKeyTypesPushdownPredicate()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can get the coverage by running tests on Cassandra 2.1. It will require some refactoring of tests though.

@findinpath findinpath force-pushed the cassandra-correct-partition-key-decoding branch from 3b5a836 to b73fc77 Compare February 3, 2022 08:39
@findinpath findinpath requested a review from ebyhr February 3, 2022 08:41
@ebyhr ebyhr merged commit a57c6c7 into trinodb:master Feb 3, 2022
@ebyhr
Copy link
Member

ebyhr commented Feb 3, 2022

Merged, thanks!

@ebyhr ebyhr mentioned this pull request Feb 3, 2022
@relistan
Copy link

relistan commented Feb 3, 2022

Awesome @findinpath @ebyhr Thanks!

@github-actions github-actions bot added this to the 370 milestone Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

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