apache / datafusion

Apache DataFusion SQL Query Engine
https://datafusion.apache.org/
Apache License 2.0
6.33k stars 1.2k forks source link

[bug]: Fix wrong order by removal from plan #13497

Open akurmustafa opened 2 days ago

akurmustafa commented 2 days ago

Which issue does this PR close?

Closes 13483.

Rationale for this change

In the 13483, final plan doesn't contain SortExec where it should. I have traced the reason and recognized that during constantness evaluation, when all children of an expression is contant expression is treated as constant. This is a valid assumption for BinaryExpr, or CastExpr. However, this shouldn't be the case for CaseExpr. This PR fixes this problem.

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?