Facepalm! This was so simple!

Thank you very much Jing and have a wonderful day !

On Fri, Nov 26, 2021, 5:18 AM Jing Zhang <[email protected]> wrote:

> Hi,
> I think you are almost close to the truth. You already find the key
> configuration `builder.transform(c -> c.withSimplify(false))`, however you
> forget to set RelBuilder to the new value.
> The solution is simple, update
> > RelBuilder builder = RelBuilder.create(config);
> > builder.transform(c -> c.withSimplify(false));
>
> to
> RelBuilder builder = RelBuilder.create(config).transform(c ->
> c.withSimplify(false));
>
> Best,
> Jing Zhang
>
>
> Florent Martineau <[email protected]> 于2021年11月24日周三 下午10:06写道:
>
> > Hi all!
> >
> > I'm using RelBuilder to create RelNodes, that I then save as JSON using
> > RelJsonWriter.
> >
> > When doing so, it seems to me that the planner rewrites my query. For
> > instance, if I set a filter that will always be false, it rewrites my
> query
> > so that it basically outputs nothing. For instance, adding this filter:
> > builder.call(SqlStdOperatorTable.GREATER_THAN, builder.literal(19),
> > builder.literal(20))
> >
> > Will yield this query:
> > SELECT * FROM (VALUES (NULL)) AS `t` (`id`) WHERE 1 = 0
> >
> > I do understand that it's the logical way to do it when planning a query.
> > Nevertheless, for my use case I would like to be able to get all the
> steps
> > that were defined using RelBuilder into my JSON, without any rewriting.
> >
> > I'm assuming this means having a kind of "DummyPlanner" that doesn't do
> any
> > rewriting, but I can't quite figure out how to do it.
> >
> > My code is as follows:
> >
> > FrameworkConfig config =
> > Frameworks.newConfigBuilder().defaultSchema(rootSchema). build();
> > RelBuilder builder = RelBuilder.create(config);
> > builder.transform(c -> c.withSimplify(false));
> >
> > RelNode node = builder
> >      .scan("schema1", "table1")
> >      .scan("schema1", "table2")
> >      .filter(builder.call(SqlStdOperatorTable.GREATER_THAN,
> > builder.literal(19), builder.literal(20)))
> >      .build();
> >
> > System.out.println(RelOptUtil.toString(node));
> > RelJsonWriter writer = new RelJsonWriter();
> > node.explain(writer);
> > System.out.println(writer.asString());
> >
> > If you have any hints that would be wonderful! Thank you!
> >
> > Florent
> >
>

Reply via email to