> On Dec 4, 2021, at 9:41 PM, Jacques Nadeau <jacq...@apache.org> wrote:
> 
> A few thoughts:
> 
> Algebra approach.
> 
> 
> If I understand the model correctly, I actually implemented this in a
> different project last year (not knowing it was now a design pattern). My
> main finding was that while it had certain benefits, it was pretty
> confusing for most people.

Thanks, Vladimir, for educating us about the algebra approach.

I have a feeling that OperandBuilder (used in the Config of many planner rules) 
uses something like this pattern. I was not aware of the algebraic approach, 
but OperandBuilder emerged as I tried to make the code type-safe and reusable.

The irony of the “algebra approach” is that Calcite is an algebra engine. And a 
very powerful one at that. People who are new to Calcite often try to use a 
visitor pattern on their RelNode tree, and we have to direct them to the 
“algebra approach” of using collections of rewrite rules to accomplish their 
task.

For this reason, I think we should keep the built-in visitors fairly simple.

Also, my work in https://issues.apache.org/jira/browse/CALCITE-4559 
<https://issues.apache.org/jira/browse/CALCITE-4559> (not finished, sadly) can 
be viewed as an attempt to convert RexSimplify (which is becoming spaghetti 
code) into something more algebraic.

Julian


Reply via email to