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

double/real truncation incorrect #14693

Closed
fgwang7w opened this issue Jun 22, 2020 · 4 comments · Fixed by #15334
Closed

double/real truncation incorrect #14693

fgwang7w opened this issue Jun 22, 2020 · 4 comments · Fixed by #15334
Assignees

Comments

@fgwang7w
Copy link
Member

Truncation of a decimal number leaves the precision as it was.
image

image


Proposed Solution:
Fix in MathFunctions truncate(num,d) to drop double's precision digits after decimal point based on the value of d

@shixuan-fan
Copy link
Contributor

I'm not particularly sure if SQL spec has definition about how truncate is supposed to work. If it is up to the engine implementation, then it sounds fine.

@fgwang7w
Copy link
Member Author

Thanks for the feedback. looks like oracle and other ansi-sql db vendors only keeps the number of digits of the decimal point per specified input d.
https://docs.oracle.com/cd/B28359_01/server.111/b28286/functions208.htm#SQLRF06150
The implementation should be as straight-forward as to add support in scalar function for truncate double by dropping digits after decimal point.

@rongrong
Copy link
Contributor

If most other databases remove trailing 0 we can change the behavior. Not sure what's the migration implications. @kaikalur thoughts?

@kaikalur
Copy link
Contributor

Spec doesn't say anything about this. Looks like it's totally implementation dependent.

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 a pull request may close this issue.

4 participants