-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[CALCITE-6702] Strong Policy for the POWER Function is wrong #4059
base: main
Are you sure you want to change the base?
Conversation
1b5cfd2
to
b8e4875
Compare
b8e4875
to
0c02bf7
Compare
Quality Gate passedIssues Measures |
@ninidhiaeddine We need a unit test for this change. |
I was thinking to add a unit test for this change, but I didn't find any existing unit tests that are checking the returned The only unit tests that I found to be remotely related are: Any ideas on what to test here exactly? Please let me know. |
@ninidhiaeddine Hi. You can add tests in sqloperatortest |
Could you please clarify? |
The Strong class is used during optimizations. |
BTW: there is another class NullPolicy which seems to overlap in functionality with Strong. That class is used during code-generation for the Enum interpreter. |
The only place where the Policy is actually used is in RexSimplify, where it is used to check whether some expressions are always null. So perhaps you can can write a SqlToRelConverter test that checks to see whether the call to POWER(null, x) is replaced in the program with a constant NULL. |
Since Strong provides only a conservative approximation, AS_IS is not wrong, it may be just a missed optimization opportunity. |
Thank you for your reply @mihaibudiu . Let's move the discussion to the Jira issue if you don't mind, since @julianhyde is probably not seeing the discussion here. I wrote my reply there. |
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 90 days if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
CALCITE-6702: Strong Policy for the
SqlStdOperatorTable.POWER
Function is wrongly assignedAS_IS
when it should beANY
.Context:
In various SQL db implementations, the
POWER(a, b)
function returnsNULL
when either or both operands are null.These are all the cases I could think of:
This means that the correct null policy for the
POWER
function isANY
instead ofAS_IS
, since this expression isNULL
if and only if at least one of its arguments isNULL
.