Skip to content

[CALCITE-5865] ClassCastException with FLOOR and CEIL on conformances that are not builtin#3327

Merged
gianm merged 1 commit intoapache:mainfrom
gianm:calcite-5865
Jul 20, 2023
Merged

[CALCITE-5865] ClassCastException with FLOOR and CEIL on conformances that are not builtin#3327
gianm merged 1 commit intoapache:mainfrom
gianm:calcite-5865

Conversation

@gianm
Copy link
Contributor

@gianm gianm commented Jul 19, 2023

CALCITE-5747 introduced some BigQuery-specific logic for FLOOR and CEIL that is keyed off the conformance being SqlConformanceEnum.BIG_QUERY. However, it was implemented in such a way that implementations of SqlConformance that are not SqlConformanceEnum would throw ClassCastException.

… that are not builtin

CALCITE-5747 introduced some BigQuery-specific logic for FLOOR and CEIL that is keyed off
the conformance being SqlConformanceEnum.BIG_QUERY. However, it was implemented in such a
way that implementations of SqlConformance that are not SqlConformanceEnum would throw
ClassCastException.
@gianm gianm added the bug label Jul 19, 2023
Copy link
Contributor

@tanclary tanclary left a comment

Choose a reason for hiding this comment

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

Thanks again for opening this fix

switch (conformance) {
case BIG_QUERY:
public static SqlOperator floorCeil(boolean floor, SqlConformance conformance) {
if (SqlConformanceEnum.BIG_QUERY.equals(conformance)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a test you can add for this?

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 thought a little about this, but I wasn't sure what kind of test to add, or where.

I could certainly add a test for this specific method verifying that a user-defined conformance works OK. But it doesn't seem likely to be a high-value test. It would be better to somehow write a test that verifies everything works with user-defined conformances. But I didn't see a way to do that after a brief look.

I'm open to thoughts here. If you think it's valuable to write a test for this specific method, LMK and I will add one. Even better, if you have an idea about how to write a more comprehensive test, LMK.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@rubenada
Copy link
Contributor

LGTM.
About the test discussion: considering we are a bit on a rush in the middle of a release process, the fix seems simple and clear; and creating a specific unit test can be cumbersome (or even an overkill), I'd agree with merging the fix as it is, without test.

@tanclary
Copy link
Contributor

@rubenada Thanks for your input, I agree with that. LGTM

@gianm gianm merged commit 94b78e9 into apache:main Jul 20, 2023
@gianm gianm deleted the calcite-5865 branch July 20, 2023 17:31
@gianm
Copy link
Contributor Author

gianm commented Jul 20, 2023

Thanks all. I have committed the patch to main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants