You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2020/03/25 18:18:00 UTC

[jira] [Commented] (CALCITE-3875) Create visitor to emit java code that would reproduce the visited rel

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

Julian Hyde commented on CALCITE-3875:
--------------------------------------

I agree that such a utility would be useful. However, it will be messy and will have a lot of dependencies, so I think it should live with the test code (e.g. next to {{class TestUtil}}).  I'm not sure that a classic visitor would work - we'd have to add a lot of junky code to the RelNode classes. Probably a utility with a big "switch", or dynamic dispatch to methods (see {{RelToSqlConverter.dispatch(RelNode)}}).

> Create visitor to emit java code that would reproduce the visited rel
> ---------------------------------------------------------------------
>
>                 Key: CALCITE-3875
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3875
>             Project: Calcite
>          Issue Type: New Feature
>    Affects Versions: 1.22.0
>            Reporter: Justin Swett
>            Priority: Minor
>
> It would be nice to have a visitor that would emit java code that could be used to reproduce the visited rel node, e.g.
> Something like:
> {code:java}
>     ...
>     String javaCode = RelOptUtil.toCode( myComplicatedRel );
>     println(javaCode);
>     // outputs something
>     final RelBuilder builder = relBuilder();
>     final RelNode root = builder
>         .scan("EMP")
>         .aggregate(builder.groupKey(),
>             builder.aggregateCall(SqlStdOperatorTable.SUM0, false, false, null,
>                 "s", builder.field(3)))
>         .build();
> {code}
> This could be useful setting up reproducible test cases that are somewhat tricky to recreate in the wild.



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