[
https://issues.apache.org/jira/browse/CALCITE-4327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17212047#comment-17212047
]
Julian Hyde commented on CALCITE-4327:
--------------------------------------
No, don't make it mutable. RelBuilder is immutable (except the runtime, e.g.
stack). Not sure why you think that's a good idea.
> RelBuilder#scan(...) should work when used in RelRule#onMatch as
> call.builder()
> -------------------------------------------------------------------------------
>
> Key: CALCITE-4327
> URL: https://issues.apache.org/jira/browse/CALCITE-4327
> Project: Calcite
> Issue Type: Sub-task
> Components: core
> Affects Versions: 1.26.0
> Reporter: Vladimir Sitnikov
> Priority: Major
>
> It turns out {{RelBuilder#relOptSchema}} is often null.
> For instance,
> {code:java}
> public abstract class RelOptRuleCall {
> public RelBuilder builder() {
> return rule.relBuilderFactory.create(rel(0).getCluster(), /* schema= */
> null);
> }
> {code}
> It leads to NPE in user code.
> I suggest either populate {{relOptSchema}} with root schema by default or
> remove the field to avoid confusion for those who would try {{scan(...)}}
> method.
> It might make sense to add RelOptSchema parameter to
> {{scan(Iterable<String>)}} method as well.
> Sample use case:
> {code:java}
> @Override
> public void onMatch(RelOptRuleCall call) {
> List<String> indexName = ...;
> RelBuilder relBuilder = call.builder()
> .scan(indexName);
> {code}
> {noformat}
> Caused by: java.lang.NullPointerException
> at org.apache.calcite.tools.RelBuilder.scan(RelBuilder.java:1094)
> at
> com.github.vlsi.mat.calcite.schema.objects.InstanceAccessByClassIdRule.onMatch(InstanceAccessByClassIdRule.java:44)
> at
> org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:229)
> ... 75 more
> {noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)