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
CASSANDRA-17818-3.11: Fix error message handling when trying to use CLUSTERING ORDER with non-clustering column #2398
base: cassandra-3.11
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me; I left just two comments on how we can improve a bit user experience and test readability
{ | ||
if (!columnAliases.contains(orderId)) | ||
{ | ||
throw new InvalidRequestException("Only clustering key columns can be defined in CLUSTERING ORDER directive"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can improve the user experience by adding the names of the columns to the exception message, similar to what Tomek did in our fork
@@ -48,4 +51,89 @@ public void testInvalidBloomFilterFPRatio() throws Throwable | |||
// sanity check | |||
createTable("CREATE TABLE %s (a int PRIMARY KEY, b int) WITH bloom_filter_fp_chance = 0.1"); | |||
} | |||
|
|||
@Test | |||
public void testCreateTableErrorOnNonClusterKey() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is plenty of repetition. We can improve readability by having a utility method and splitting the test into a few small ones; each test name will reflect exactly what we test. Tomek already has something similar in our fork. You can check it and get inspired by it. We can mark him as then co-author on the ticket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 with @ekaterinadimitrova2
add column name to error message
add column name to error message
@@ -48,4 +51,89 @@ public void testInvalidBloomFilterFPRatio() throws Throwable | |||
// sanity check | |||
createTable("CREATE TABLE %s (a int PRIMARY KEY, b int) WITH bloom_filter_fp_chance = 0.1"); | |||
} | |||
|
|||
@Test | |||
public void testCreateTableErrorOnNonClusterKey() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 with @ekaterinadimitrova2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, +1
Just a typo, and a few names need to be corrected on commit; thank you!
} | ||
|
||
@Test | ||
public void testCreateTableInWrongOrdering() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void testCreateTableInWrongOrdering() | |
public void testCreateTableInWrongOrder() |
to be corrected on commit
} | ||
|
||
@Test | ||
public void testCreateTableWithMissingClusterColumn() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void testCreateTableWithMissingClusterColumn() | |
public void testCreateTableWithMissingClusteringColumn() |
to be fixed on commit
createTable("CREATE TABLE %s (pk int, ck1 int, ck2 int, v int, PRIMARY KEY ((pk),ck1, ck2)) WITH CLUSTERING ORDER BY (ck1 ASC, ck2 DESC);"); | ||
} | ||
@Test | ||
public void testCreateTableErrorOnNonClusterKey() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void testCreateTableErrorOnNonClusterKey() | |
public void testCreateTableErrorOnNonClusteringKey() |
to be corrected on commit
} | ||
|
||
@Test | ||
public void testCreateTableOnAllClusterColumns() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void testCreateTableOnAllClusterColumns() | |
public void testCreateTableOnAllClusterColumns() |
to be corrected on commit
@@ -48,4 +51,60 @@ public void testInvalidBloomFilterFPRatio() throws Throwable | |||
// sanity check | |||
createTable("CREATE TABLE %s (a int PRIMARY KEY, b int) WITH bloom_filter_fp_chance = 0.1"); | |||
} | |||
|
|||
@Test | |||
public void testCreateTableOnSelectedClusterColumn() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void testCreateTableOnSelectedClusterColumn() | |
public void testCreateTableOnSelectedClusteringColumn() |
to be corrected on commit
|
||
if (!nonClusterColumn.isEmpty()) | ||
{ | ||
throw new InvalidRequestException("Only clustering key columns can be defined in CLUSTERING ORDER directive: " + nonClusterColumn + " are not clustering column"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new InvalidRequestException("Only clustering key columns can be defined in CLUSTERING ORDER directive: " + nonClusterColumn + " are not clustering column"); | |
throw new InvalidRequestException("Only clustering key columns can be defined in CLUSTERING ORDER directive: " + nonClusterColumn + " are not clustering columns"); |
to be corrected on commit
Fix error message handling when trying to use CLUSTERING ORDER with non-clustering column
Patch: Throw error message after finding there are non-cluster columns in order definition.
patch by
The Cassandra Jira