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

Minior: Add negative tests about log function #9245

Merged
merged 2 commits into from
Feb 19, 2024
Merged

Conversation

caicancai
Copy link
Member

Which issue does this PR close?

Fractions in the log function are an important test because the results of 2.0/3 and 2/3 are completely different

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Feb 16, 2024
@caicancai caicancai marked this pull request as draft February 16, 2024 12:42
@caicancai
Copy link
Member Author

caicancai commented Feb 16, 2024

@alamb Hello, I have a question about logX(0). In arrow-datafusion, logX(0) returns -Infinity. From a mathematical point of view, I think there is no problem. However, I tested that mysql returns null and postgres returns error. , consider modifying the arrow-datafusion part.
calcite is currently experiencing similar problems

@gruuya
Copy link
Contributor

gruuya commented Feb 16, 2024

In arrow-datafusion, logX(0) returns -Infinity.
consider modifying the arrow-datafusion part.

On a similar note the log with base zero returns zero

select log(0, 3);
+------------------------+
| log(Int64(0),Int64(3)) |
+------------------------+
| 0.0                    |
+------------------------+

Mathematically that's undefined, while in Postgres/DuckDB it leads to an error (cannot take logarithm of zero).

@caicancai
Copy link
Member Author

caicancai commented Feb 18, 2024

Mathematically that's undefined, while in Postgres/DuckDB it leads to an error (cannot take logarithm of zero).

I think log2, log10, and log should be the same set of functions, which is fine, and maybe we all feel that the current handling of log10(0) could be improved

@Jefffrey
Copy link
Contributor

FYI some relevant previous discussion/work on log:

@caicancai
Copy link
Member Author

FYI some relevant previous discussion/work on log:

* [Make `log` function to be in sync with PostgresSql #5259](https://github.com/apache/arrow-datafusion/issues/5259)

* [[DOC] Update math expression documentation  #5316](https://github.com/apache/arrow-datafusion/pull/5316)

Thank you for your reply. I'm sorry that I didn't notice the content in the document before.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @caicancai for adding the tests to document this feature more fully in code

I am hoping this type of "what should log do in corner cases" will have a better story once we have done #8045 -- and thus if someone wants a different set of log function behavior they can just register a different log UDF

@caicancai
Copy link
Member Author

caicancai commented Feb 19, 2024

Thank you @caicancai for adding the tests to document this feature more fully in code

I am hoping this type of "what should log do in corner cases" will have a better story once we have done #8045 -- and thus if someone wants a different set of log function behavior they can just register a different log UDF

so cool, I think this is a very good idea, as a single sql engine can output the corresponding result expected by the user according to the user's custom behavior, which means that we do not need to adapt the negative test of each function in any dialect, but only need to concentrate on adapting most of the common functions.

Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

lgtm thanks @caicancai

@comphead comphead merged commit 5f55b6e into apache:main Feb 19, 2024
23 checks passed
@caicancai caicancai deleted the log branch February 20, 2024 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants