-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add SQL function overload LOG(base, x) for logarithm of x to base #5245
Conversation
@stuartcarnie @alamb with
whereas PostgresSQL doesn't allow queries like that and fail the query |
For anyone else who is curious, here is what postgres does with this query: postgres=# select log(0);
ERROR: cannot take logarithm of zero
postgres=# select log(1, 64);
ERROR: division by zero |
Thank you very much for this contribution @comphead |
@alamb would you like to solve edgecases as part of this PR or another one? |
A different one, please |
# under the License. | ||
|
||
############# | ||
## Scalar Tests |
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.
## Scalar Tests | |
## Scalar Function Tests |
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.
Done
# log scalar nulls 2 | ||
query IT rowsort | ||
select log(null, null) a, log(null) b | ||
---- |
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.
Can you please add the test cases you identified in the PR here (log(0), log(1, 64)) as well to document the behavior and also file a ticket to document the discrepancy?
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.
Done, filed #5259
Thanks @comphead -- this looks really great. cc @stuartcarnie |
Looks great, thanks @comphead 🙏 I tried to look at the source of PostgreSQL, to see the implementation of their |
Thanks again @comphead |
Benchmark runs are scheduled for baseline = 0f95966 and contender = 8a609dc. 8a609dc is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Which issue does this PR close?
Closes #5206 .
Rationale for this change
Add SQL function overload LOG(base, x) for logarithm of x to base
What changes are included in this PR?
Are these changes tested?
Test included
Are there any user-facing changes?
No