[ 
https://issues.apache.org/jira/browse/CALCITE-2970?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17077429#comment-17077429
 ] 

Julian Hyde commented on CALCITE-2970:
--------------------------------------

bq. RelBuilder should be used for logical operators only

I disagree. Building any RelNode can be quite complex. For example, if the 
input has a distribution trait, you need to make sure that that trait is 
propagated to the outputs. And you need to derive the names, types and 
nullability of the output fields. And it's useful to carry out simplifications.

That logic needs to live somewhere. It can't live in the constructor of the 
RelNode base class (e.g. Filter) because complex constructors are an 
anti-pattern. We used to have it live in {{create}} methods (e.g. 
{{LogicalFilter.create}}) and in {{RelOptUtil}}, but re-use wasn't great. 
{{RelBuilder}} is the right place for it.

Of course if you're simply converting logical to physical - e.g. LogicalFilter 
to MongoFilter - then you're probably copying most fields, and you can do 
without a RelBuilder. But physical rules do more than convert logical to 
physical.

Note that you can create a physical {{RelBulder}} by swapping out its 
[RelBuilder.struct 
field|https://github.com/apache/calcite/blob/38e2566178dedf2aafe5700dd8fc45b9b30153da/core/src/main/java/org/apache/calcite/tools/RelBuilder.java#L153]
 for one that contains factories for the particular convention you are 
targeting.

> Performance issue when enabling abstract converter for EnumerableConvention
> ---------------------------------------------------------------------------
>
>                 Key: CALCITE-2970
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2970
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Haisheng Yuan
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 12h
>  Remaining Estimate: 0h
>
> If we enable the use of abstract converter for {{EnumerableConvention}}, by 
> making {{useAbstractConvertersForConversion}} return true, 
> {{JDBCTest.testJoinManyWay}} will not complete.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to