Re: Is there a mechanism for constant folding in Calcite?

2021-10-27 Thread Stamatis Zampetakis
Hi Ian, As Alessandro correctly said, the engine relies on scalar subqueries being unnested. Rules are not applied to RexSubquery expressions. In a relatively recent discussion [1] somebody else also expressed the need to retain nesting in scalar subqueries. I think that if somebody pushes this

Re: Is there a mechanism for constant folding in Calcite?

2021-10-26 Thread Alessandro Solimando
Hi Ian, regarding commutativity/associativity I think this ML discussion could be relevant and it has some pointers. For what concerns decorrelation, I think that most

Re: Is there a mechanism for constant folding in Calcite?

2021-10-26 Thread Ian Bertolacci
Thanks! I've just tried it out, and it does work for lot of our cases. But I've noticed that it doesn't fold expressions that could be reordered under associativity rules. For example `+( $1, +( 10, 20 ) )` is folded to `+( $1, 30 )`, but the left-deep equivalent `+( +( $1, 10 ), 20 )` is not

Re: Is there a mechanism for constant folding in Calcite?

2021-10-25 Thread Julian Hyde
Chunwei is correct. If there are expressions that you would expect to constant-folded by that rule that aren’t, please log a bug. > On Oct 25, 2021, at 7:10 PM, Chunwei Lei wrote: > > Hi, Ian. > > ReduceExpressionsRule is always used to do constant folding. > > > Best, > Chunwei > > > On

Re: Is there a mechanism for constant folding in Calcite?

2021-10-25 Thread Chunwei Lei
Hi, Ian. ReduceExpressionsRule is always used to do constant folding. Best, Chunwei On Tue, Oct 26, 2021 at 4:34 AM Ian Bertolacci wrote: > Howdy, > Does Calcite have any mechanism for applying constant folding to RexNodes > in a query? > > We’ve been wondering why expressions like `1 + 2`

Is there a mechanism for constant folding in Calcite?

2021-10-25 Thread Ian Bertolacci
Howdy, Does Calcite have any mechanism for applying constant folding to RexNodes in a query? We’ve been wondering why expressions like `1 + 2` don’t get folded into the constant `3`. We’re aware of RexSimplify, but it only does constant folding for Boolean expressions (i.e. logical and (some)