[ https://issues.apache.org/jira/browse/CALCITE-3972?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17101144#comment-17101144 ]
Xiening Dai commented on CALCITE-3972: -------------------------------------- If convention is considered as part of the config, then it looks weird that adoptConvention() preserves builder stack while RelBuilder#transform(UnaryOperator<Config> transform) does not. Furthermore, a common usage pattern like below won't work because the builder object referenced by filter is not the one after adoptConvention() - {code:java} RelNode root = builder.adoptConvention(EnumerableConvention.INSTANCE) .scan("EMP") .filter( builder.equals(builder.field("DEPTNO"), builder.literal(20))) .build(); {code} In my view, if we'd like to support switching convention in the middle of building nodes, we should treat convention as a mutable state - just like stake. Or we abandon such capability, and don't preserve stake when switching convention. In that case, we don't need adoptConvention(), modifying current transform() should be enough. > Allow RelBuilder to create RelNode with convention and use it for trait > convert > ------------------------------------------------------------------------------- > > Key: CALCITE-3972 > URL: https://issues.apache.org/jira/browse/CALCITE-3972 > Project: Calcite > Issue Type: Bug > Reporter: Xiening Dai > Assignee: Xiening Dai > Priority: Major > Fix For: 1.23.0 > > Time Spent: 40m > Remaining Estimate: 0h > > 1. Provide Convention.transformRelBuilder() to transform an existing > RelBuilder into one with specific convention. > 2. RelBuilder provides withRelFactories() method to allow caller swap the > underlying RelFactories and create a new builder. > 3. Use the new interface in RelCollationTraitDef for converting into > RelCollation traits > We can avoid ~1/3 of total rule firings in a N way join case with this change. -- This message was sent by Atlassian Jira (v8.3.4#803005)