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

Adds tests for checking DECIMAL types #95

Merged
merged 1 commit into from
May 29, 2024
Merged

Adds tests for checking DECIMAL types #95

merged 1 commit into from
May 29, 2024

Conversation

yliuuuu
Copy link
Contributor

@yliuuuu yliuuuu commented Jun 12, 2023

Issue #71

Description of changes:

  • Add IS operator test for decimal type.
  • Add invalid decimal type parameter to fail/staticAnalysis

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@RCHowell
Copy link
Contributor

Could you briefly explain the rules for DECIMAL type and IS operator? How to lower-scale and lower-precision values compare with high-scale and/or high-precision types and visa-versa. Thank you for adding these tests.

Comment on lines +39 to +40
name: "123.456 is DECIMAL(2,2)",
statement: "123.456 is DECIMAL(2,2)",
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please explain how 123.456 with three decimal places is considered a decimal with scale 2? Similarly, how is the precision only 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The output is false.
So in general I believe that semantically decimal(p,s) means the underlying data value has upto p numeric digits, and exactly s digit after the decimal point.

I don't think the is operator is specified in the SQL spec, but based on the implementation, I believe x is T, where x is a value and T is a Type, is saying that x can be "hold" by T without truncate or rounding.

For example, we can store 123.456 as DECIMAL(6,3), we can also store it in DECIMAL(7,4) without truncate or rounding. (we append trailing zeros)

Hence both 123.456 is DECIMAL(6,3) and 123.456 is DECIMAL(7,4) should return true.

That said, it is based on our current kotlin-implementation and was not documented any where as far as i know.

I can open up an issue to track the decimal semantic documentation in PartiQL-docs if necessary.

But for IS operator, curious if you think we should track this in lang-kotlin or partiql-doc (i.e., spec issue or implementation issue)

@yliuuuu yliuuuu requested a review from RCHowell June 21, 2023 16:25
@RCHowell RCHowell changed the title decimal op Adds tests for checking DECIMAL types May 29, 2024
@RCHowell RCHowell merged commit daf9234 into main May 29, 2024
@RCHowell RCHowell deleted the deicmal_op branch May 29, 2024 17:28
alancai98 pushed a commit that referenced this pull request Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants