datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

Add interface to determine whether expr is a constant

Open liukun4515 opened this issue 2 years ago • 3 comments

for datafusion, we need to add interface which is used to identify the expr is constant or literal or not. If we have this interface, we can make more optimization. But the interface should be better in the logical expr not in the physical expr like sprak fold

Originally posted by @liukun4515 in https://github.com/apache/arrow-datafusion/pull/2834#discussion_r913453698

liukun4515 avatar Jul 05 '22 07:07 liukun4515

this feature can be used to do some optimization in plan optimizer or expression folding

liukun4515 avatar Jul 05 '22 07:07 liukun4515

In my mind, if we we always ran 'constant folding' on an Expr then checking for a constant should be a matter of calling matches!(expr, Expr::Literal)

In other words, I had hoped that the constant folding pass was a general purpose mechanism to detect constants

alamb avatar Jul 08 '22 19:07 alamb

In my mind, if we we always ran 'constant folding' on an Expr then checking for a constant should be a matter of calling matches!(expr, Expr::Literal)

In other words, I had hoped that the constant folding pass was a general purpose mechanism to detect constants

I go through the code about optimizer and simplify expr, and find some codes about constant folding. I will take more time to look this carefully and give my feedback.

liukun4515 avatar Jul 12 '22 01:07 liukun4515