-
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
Minor: support complex expr as the arg in the ApproxPercentileCont function #8580
Conversation
dfb84fe
to
4a8741b
Compare
4a8741b
to
2cf286c
Compare
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.
Thanks @liukun4515 -- this PR seems to fix the problem and has a test so 👍
This doesn't seem like it is a problem that is specific to approx_percentile_cont
-- there might be a way to make it more general but we could also always do that as a follow on PR
@@ -186,6 +187,25 @@ async fn test_fn_approx_percentile_cont() -> Result<()> { | |||
|
|||
assert_batches_eq!(expected, &batches); | |||
|
|||
// the arg2 parameter is a complex expr, but it can be evaluated to the literal value |
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.
I think this may be related to aliasing rather than simply complex expressions
❯ create table t (x int) as values (1), (2);
0 rows in set. Query took 0.001 seconds.
❯ select APPROX_PERCENTILE_CONT(x, cast(1 as double)) from t;
+--------------------------------------+
| APPROX_PERCENTILE_CONT(t.x,Int64(1)) |
+--------------------------------------+
| 2 |
+--------------------------------------+
1 row in set. Query took 0.002 seconds.
However, I couldn't express the same alias using SQL.
I wonder if the expression simplifier code could be generalized to handle this case, so it applied to all arguments, not just the arguments to APPROX_PERCENTILE_CONT
🤔
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.
yes, the rule of simplfy_expression
can not handle the alisa expr.
But the cast(1 as float)
will be simplified.
I think this is the diff between the cast and alisa
Yes this pr is a quick fix for the issue. We can enchancement the rule of |
Which issue does this PR close?
Closes #.
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?