[CALCITE-5861] Optimization rules do not constant-fold expressions in window bounds#3328
[CALCITE-5861] Optimization rules do not constant-fold expressions in window bounds#3328asolimando merged 1 commit intoapache:mainfrom
Conversation
|
I would very much appreciate a review for this tiny PR. |
I agree on separating the two problems and filing a separate Jira about moving the window bound expressions in a projection. |
|
@mihaibudiu, if you file a different ticket for the projection part, I guess the test you added will look different and involve only In addition, in general, we tend to phrase the Jira ticket titles a bit differently though, something like "ReduceExpressionsRule rules should constant-fold expressions in window bounds", WDYT? |
|
In the JIRA ticket discussion @julianhyde said this:
So I think based on this interpretation a second issue will not be necessary. I will rename the issue as you suggested. |
…ssions in window bounds Signed-off-by: Mihai Budiu <mbudiu@gmail.com>
|
Kudos, SonarCloud Quality Gate passed! |
|
Maybe someone can merge this? |








With this change the PROJECT_REDUCE_EXPRESSIONS rule will also optimize constants that appear in window bound expressions. This makes it possible to compile programs that use (constant) expressions in window bounds.
However, I suspect that the rule PROJECT_TO_LOGICAL_PROJECT_AND_WINDOW is still buggy, since it will move window bound expressions into separate projections, as described in the JIRA case. Unfortunately I could not figure out how to fix that rule - the code is very generic and treats all expressions in the same way, regardless where they appear in the RexNode. Perhaps I should file another JIRA issue about this?