-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Minor: add test + docs for 2 argument trunc with columns #7042
Changes from 2 commits
f7110e6
a65ffce
ac1ad48
2e53946
47b74fe
03294de
2b05521
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -507,14 +507,17 @@ tanh(numeric_expression) | |
Truncates a number toward zero (at the decimal point). | ||
|
||
``` | ||
trunc(numeric_expression) | ||
trunc(numeric_expression[, decimal_places]) | ||
``` | ||
|
||
#### Arguments | ||
|
||
- **numeric_expression**: Numeric expression to operate on. | ||
Can be a constant, column, or function, and any combination of arithmetic operators. | ||
|
||
- **decimal_places**: Optional. The number of decimal places to truncate to. | ||
Defaults to 0. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doc looks good to me. Just one question. Can There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can not be negative, modify the trunc function just meet the self-defined precision of decimal to '.' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL turns out that negative precision means "truncate to the left of the decimal place": https://www.postgresqltutorial.com/postgresql-math-functions/postgresql-trunc/#:~:text=If%20the%20precision%20argument%20is,The%20precision%20argument%20is%20optional.
This is actually what the current datafusion implementation does too so I have added a test and updated the docs |
||
|
||
## Conditional Functions | ||
|
||
- [coalesce](#coalesce) | ||
|
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.
Hmm, as
a
has at most 1 decimal point,trunc(a, 3)
ortrunc(a, 1)
basically cannot show the difference. I think it doesn't actually test what we want?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.
maybe add some long decimal point float number
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.
Added