Minor: support complex expr as the arg in the ApproxPercentileCont function#8580
Minor: support complex expr as the arg in the ApproxPercentileCont function#8580liukun4515 merged 2 commits intoapache:mainfrom
Conversation
dfb84fe to
4a8741b
Compare
4a8741b to
2cf286c
Compare
alamb
left a comment
There was a problem hiding this comment.
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
|
|
||
| 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.
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.
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?