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

CASSANDRA-17818-3.11: Fix error message handling when trying to use CLUSTERING ORDER with non-clustering column #2398

Open
wants to merge 6 commits into
base: cassandra-3.11
Choose a base branch
from

Conversation

qannap
Copy link
Contributor

@qannap qannap commented Jun 8, 2023

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

Copy link
Contributor

@ekaterinadimitrova2 ekaterinadimitrova2 left a 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");
Copy link
Contributor

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()
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -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()
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@ekaterinadimitrova2 ekaterinadimitrova2 left a 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()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public void testCreateTableInWrongOrdering()
public void testCreateTableInWrongOrder()

to be corrected on commit

}

@Test
public void testCreateTableWithMissingClusterColumn()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public void testCreateTableErrorOnNonClusterKey()
public void testCreateTableErrorOnNonClusteringKey()

to be corrected on commit

}

@Test
public void testCreateTableOnAllClusterColumns()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants