-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Enable and fix all Cassandra connector tests in CI #26022
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
Enable and fix all Cassandra connector tests in CI #26022
Conversation
Reviewer's GuideThis PR re-enables Cassandra connector tests in CI by updating test classes to ensure proper cleanup, adapting expected results to recent SHOW COLUMNS enhancements, overriding unsupported tests as no-ops, and adjusting build configurations and CI workflows to include the full Cassandra test suite. Class diagram for updated Cassandra test classesclassDiagram
class TestCassandraDistributed {
+setUp()
+tearDown()
+testCases()
-overriddenUnsupportedTests()
}
class TestCassandraIntegrationSmokeTest {
+setUp()
+tearDown()
+testShowColumns()
-adaptedExpectedResults()
-overriddenUnsupportedTests()
}
class TestCassandraTokenSplitManager {
+setUp()
+tearDown()
+testTokenSplits()
-overriddenUnsupportedTests()
}
TestCassandraDistributed <|-- TestCassandraIntegrationSmokeTest
TestCassandraDistributed <|-- TestCassandraTokenSplitManager
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes - here's some feedback:
- The repetitive try–finally cleanup logic in many tests could be extracted into a shared helper or an @after method to reduce boilerplate.
- Overriding dozens of unsupported test methods as no-ops clutters TestCassandraDistributed — consider filtering them at the base class or using a suite-level exclude instead.
- The new Maven profile id “ci-full-tests” is generic; renaming it to something more descriptive like “cassandra-integration-tests” would improve clarity.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The repetitive try–finally cleanup logic in many tests could be extracted into a shared helper or an @After method to reduce boilerplate.
- Overriding dozens of unsupported test methods as no-ops clutters TestCassandraDistributed — consider filtering them at the base class or using a suite-level exclude instead.
- The new Maven profile id “ci-full-tests” is generic; renaming it to something more descriptive like “cassandra-integration-tests” would improve clarity.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
imjalpreet
left a comment
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.
Thank you, @bibith4. I have a few suggestions and clarifications.
| @Override | ||
| @Parameters("storageFormat") | ||
| @Test | ||
| public void testAddDistinctForSemiJoinBuild(@Optional("PARQUET") String storageFormat) |
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.
What is the reason for this override?
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.
@imjalpreet In AbstractTestQueries, we currently cast o.orderdate to DATE only when the format is "DWRF":
String orderdate = format.equals("DWRF") ? "cast(o.orderdate as DATE)" : "o.orderdate";
As a result, when the test data has orderdate as VARCHAR and the format is not "DWRF", o.orderdate remains a string, causing the date comparison to fail.
To fix this, changed the code to cast o.orderdate to DATE regardless of the format.
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.
I see that, since the Cassandra connector doesn’t rely on formats, they aren’t relevant here.
Because we only want orderdate to be connector-specific, instead of duplicating the entire test, we could introduce a method in AbstractTestDistributedQueries with a default implementation that defines whether orderdate needs casting. Then, we’d only need to override that method in TestCassandraDistributed.
| @Override | ||
| @Parameters("storageFormat") | ||
| @Test | ||
| public void testQueryWithEmptyInput(@Optional("PARQUET") String storageFormat) |
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.
What is the reason for this override?
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.
@imjalpreet In AbstractTestQueries, we currently cast o.orderdate to DATE only when the format is "DWRF":
String orderdate = format.equals("DWRF") ? "cast(o.orderdate as DATE)" : "o.orderdate";
As a result, when the test data has orderdate as VARCHAR and the format is not "DWRF", o.orderdate remains a string, causing the date comparison to fail.
To fix this, changed the code to cast o.orderdate to DATE regardless of the format.
| emptyJoinQueries(enableOptimization); | ||
| } | ||
|
|
||
| private void emptyJoinQueries(Session session) |
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.
What is the reason for this override?
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.
@imjalpreet The emptyJoinQueries() method was not overridden. It is used by testQueryWithEmptyInput().
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.
Once we refactor as I suggested, we won't need to copy this method as well.
| assertSelect("table_all_types_copy", true); | ||
| } | ||
| finally { | ||
| execute("DROP TABLE table_all_types_copy"); |
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.
| execute("DROP TABLE table_all_types_copy"); | |
| execute("DROP TABLE IF EXISTS table_all_types_copy"); |
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.
Corrected . Please check
| assertEquals(execute("SELECT column_1 FROM cassandra.keyspace_1.table_1").getRowCount(), 1); | ||
| } | ||
| finally { | ||
| assertUpdate("DROP TABLE cassandra.keyspace_1.table_1"); |
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.
| assertUpdate("DROP TABLE cassandra.keyspace_1.table_1"); | |
| assertUpdate("DROP TABLE IF EXISTS cassandra.keyspace_1.table_1"); |
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.
Corrected . Please check
| assertEquals(execute("SELECT column_2 FROM cassandra.keyspace_2.table_2").getRowCount(), 1); | ||
| } | ||
| finally { | ||
| assertUpdate("DROP TABLE cassandra.keyspace_2.table_2"); |
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.
| assertUpdate("DROP TABLE cassandra.keyspace_2.table_2"); | |
| assertUpdate("DROP TABLE IF EXISTS cassandra.keyspace_2.table_2"); |
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.
Corrected . Please check
| assertEquals(splits.size(), 1); | ||
| } | ||
| finally { | ||
| session.execute(format("DROP TABLE %s.%s", KEYSPACE, tableName)); |
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.
| session.execute(format("DROP TABLE %s.%s", KEYSPACE, tableName)); | |
| session.execute(format("DROP TABLE IF EXISTS %s.%s", KEYSPACE, tableName)); |
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.
Corrected . Please check
| assertEquals(splits.size(), PARTITION_COUNT / SPLIT_SIZE); | ||
| } | ||
| finally { | ||
| session.execute(format("DROP TABLE %s.%s", KEYSPACE, tableName)); |
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.
| session.execute(format("DROP TABLE %s.%s", KEYSPACE, tableName)); | |
| session.execute(format("DROP TABLE IF EXISTS %s.%s", KEYSPACE, tableName)); |
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.
Corrected . Please check
7a33dfe to
e7148f3
Compare
imjalpreet
left a comment
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.
Thanks, @bibith4.
I have a suggestion that should help reduce duplication.
| @Override | ||
| @Parameters("storageFormat") | ||
| @Test | ||
| public void testAddDistinctForSemiJoinBuild(@Optional("PARQUET") String storageFormat) |
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.
I see that, since the Cassandra connector doesn’t rely on formats, they aren’t relevant here.
Because we only want orderdate to be connector-specific, instead of duplicating the entire test, we could introduce a method in AbstractTestDistributedQueries with a default implementation that defines whether orderdate needs casting. Then, we’d only need to override that method in TestCassandraDistributed.
| emptyJoinQueries(enableOptimization); | ||
| } | ||
|
|
||
| private void emptyJoinQueries(Session session) |
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.
Once we refactor as I suggested, we won't need to copy this method as well.
presto-cassandra/pom.xml
Outdated
| <configuration> | ||
| <includes> | ||
| <include>**/TestCassandraIntegrationSmokeTest.java</include> | ||
| </includes> | ||
| </configuration> |
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.
nit: please remove this empty configuration property
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.
@imjalpreet Corrected. Can you please check
206a3d4 to
e40a2ef
Compare
imjalpreet
left a comment
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.
Thank you, @bibith4.
LGTM % minor refactor.
|
|
||
| /** | ||
| By default, casts only when storageFormat is DWRF. | ||
| */ | ||
| protected String getOrderDateExpression(String storageFormat) | ||
| { | ||
| // DWRF does not support date type. | ||
| return storageFormat.equals("DWRF") ? "cast(o.orderdate as DATE)" : "o.orderdate"; | ||
| } | ||
|
|
||
| /** | ||
| By default, casts only when storageFormat is DWRF. | ||
| */ | ||
| protected String getShipDateExpression(String storageFormat) | ||
| { | ||
| // DWRF does not support date type. | ||
| return storageFormat.equals("DWRF") ? "cast(l.shipdate as DATE)" : "l.shipdate"; | ||
| } |
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.
| /** | |
| By default, casts only when storageFormat is DWRF. | |
| */ | |
| protected String getOrderDateExpression(String storageFormat) | |
| { | |
| // DWRF does not support date type. | |
| return storageFormat.equals("DWRF") ? "cast(o.orderdate as DATE)" : "o.orderdate"; | |
| } | |
| /** | |
| By default, casts only when storageFormat is DWRF. | |
| */ | |
| protected String getShipDateExpression(String storageFormat) | |
| { | |
| // DWRF does not support date type. | |
| return storageFormat.equals("DWRF") ? "cast(l.shipdate as DATE)" : "l.shipdate"; | |
| } | |
| /** | |
| * Returns a date expression, casting to DATE if storageFormat is DWRF. | |
| */ | |
| protected String getDateExpression(String storageFormat, String columnExpression) | |
| { | |
| // DWRF does not support date type. | |
| return storageFormat.equals("DWRF") ? "cast(" + columnExpression + " as DATE)" : columnExpression; | |
| } |
nit: good to refactor
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.
@imjalpreet Refactored the code as per suggestion. Can you please check
e40a2ef to
1fb914c
Compare
1fb914c to
9a22377
Compare
imjalpreet
left a comment
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.
Thank you, @bibith4.
|
@tdcmeehan, can you please help review this? Also, we need to modify the required check as the profile name is not |
Description
Enable and fix all Cassandra connector tests in CI
Motivation and Context
Cassandra test cases were not enabled in the CI. After the PR #25351
to enhance SHOW COLUMNS was merged, some Cassandra test cases started failing. This change re-enables the Cassandra tests and fixes the test failures.
Impact
Enabled all cassandra tests
Test Plan
Contributor checklist
Release Notes