-
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
rewrite nvl function #9413
rewrite nvl function #9413
Conversation
I think that this manner of rewriting might have several downsides that need to be considered.
On this PR's branch: DataFusion CLI v36.0.0
❯ select nvl(1);
Error during planning: Invalid function 'nvl'.
Did you mean 'nanvl'? The hint on the main branch would be better.
I have performed such a test on this branch.
There is approximately a 25% chance of an incorrect result. ❯ select count(*) from (
select
nvl(nullif(random()>0.5, true), false)
from (unnest(range(1,10000)))
) as t(a)
where a is null;
+----------+
| COUNT(*) |
+----------+
| 2517 |
+----------+ |
@@ -311,4 +318,33 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { | |||
} | |||
} | |||
} | |||
|
|||
fn all_suger_function() -> &'static [&'static str] { |
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.
This can be a const
const NVL_ALIAS: &'static [&'static str] = ...
planner_context: &mut PlannerContext, | ||
) -> Result<Option<Expr>> { | ||
match (name, args) { | ||
// rewirte nvl function to nvl2 function |
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.
// rewirte nvl function to nvl2 function | |
// rewrite nvl function to nvl2 function |
yes, need to redesign rewrite manner |
Marking this PR as draft as I don't think it is waiting for more review (and I am trying to get through the PR review backlog). Do we have any alternate approaches? Or is the plan to leave both |
Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days. |
Which issue does this PR close?
Closes #9365 .
Rationale for this change
now,
nvl2
function is supported, so we don't need keep nvl code, we can rewritenvl
tonvl2
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?