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

[CALCITE-6389] RexBuilder.removeCastFromLiteral does not preserve semantics for some… #3779

Merged
merged 1 commit into from May 10, 2024

Conversation

mihaibudiu
Copy link
Contributor

… types of literal

There are at least two other issues that I attempted to fix which uncover this bug, so I decided to make a separate PR for fixing it. This should make the other PRs simpler and less controversial.

@mihaibudiu mihaibudiu changed the title RexBuilder.removeCastFromLiteral does not preserve semantics for some… [CALCITE-6389] RexBuilder.removeCastFromLiteral does not preserve semantics for some… May 7, 2024
…antics for some types of literal

Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
Copy link

sonarcloud bot commented May 7, 2024

return true;
}
value = value.stripTrailingZeros();
if (value.scale() < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be great also to have a test with negative scale

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Frankly negative scales are something I don't understand well.
Many SQL dialects do not accept negative scales, but Calcite allegedly does, although there aren't many tests about that.
Maybe we can file a separate issue about testing negative scales in Calcite, I expect it may uncover quite a few bugs.

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 also think that whether negative scales are accepted or not should be a property of the type system.

Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't checked it however if you think that it is large area to work with, then separate issue could be probably also ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think that many places in Calcite assume implicitly that decimal scales cannot be negative.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do we do about this PR in particular?

Copy link
Contributor

Choose a reason for hiding this comment

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

as you mentioned if there is a separate issue for negative scale is required, could you please file one in Calcite jira?
All the rest is ok to me, thanks

@mihaibudiu mihaibudiu merged commit c228804 into apache:main May 10, 2024
17 checks passed
@mihaibudiu mihaibudiu deleted the issue6389 branch May 10, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants