2

I am building a RelNode using RelBuilder.

FrameworkConfig frameworkConfig = config().build();
 final RelBuilder builder = RelBuilder.create(frameworkConfig);
  RelNode root =
                 builder.scan("ITEM", "TEST")
                 .filter(
                         builder.equals(builder.field("ITEM_ID"), builder.literal("AM_TestItem_21Aug17_0614")))
                 .filter(
                        builder.equals(builder.field("OBJECT_TYPE"), builder.literal("Item")))
                 .build();

 PreparedStatement preparedStatement = RelRunners.run(root)
 preparedStatement.executeQuery()
    public static Frameworks.ConfigBuilder config() {
        CalciteSchema rootSchema1 = CalciteSchema.createRootSchema(true);
        rootSchema1 = rootSchema1.add("ITEM", new MySchema());
        // MySchema consists of Map of MyFilterableTable which extends AbstractTable and implements FilterableTable
        return Frameworks.newConfigBuilder().defaultSchema(rootSchema1.plus());
    }

scan method in MyFilterableTable public Enumerable<Object[]> scan(DataContext root, List<RexNode> filters) gets merged filter string as [AND(=($0, 'AM_TestItem_21Aug17_0614'), =($3, 'Item'))]

I want separate entries of these filters and not merged one. I want planner to ignore the FilterMergeRule.

Is there any way to do that?

1 Answers1

1

There is no easy way to selectively enable/disable rules when using the RelBuilder API and this is normal given that this API is meant only to create plans.

Moreover it is not a good idea to rely on the fact that the filters will not be merged since there is a high chance that in the future the merge that is currently done via FilterMergeRule could be done with the RelBuilder when there are two adjacent filter operators.

Nevertheless, inside the scan operation you could call RelOptUtil#conjunctions method which splits the filter into separate conjunctions which is more or less what you would like to obtain if I understand well your use-case.

zabetak
  • 412
  • 4
  • 13