You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Vladimir Sitnikov (JIRA)" <ji...@apache.org> on 2018/08/10 21:48:00 UTC

[jira] [Comment Edited] (CALCITE-2462) RexProgramTest: move "rex building" methods to base class

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

Vladimir Sitnikov edited comment on CALCITE-2462 at 8/10/18 9:47 PM:
---------------------------------------------------------------------

Alternative option would be to use interface like the following
{code:java}
public interface RexProgramBuilderBase {
    RexBuilder getRexBuilder();
    
    default RexNode add(RexNode n1, RexNode n2) {
      return getRexBuilder().makeCall(SqlStdOperatorTable.PLUS, n1, n2);
    }
...
}
{code}

It would release the need to extend {{class RexProgramBuilderBase}}, however it is not clear where local fields should be stored (e.g. private {{Map<RelDataType, RexDynamicParam> dynamicParams;}} and so on)
So I think {{abstract base class}} should be just fine for now.


was (Author: vladimirsitnikov):
Alternative option would be to use interface like the following
{code:java}
public interface RexProgramBuilderBase {
    RexBuilder getRexBuilder();
    
    default RexNode add(RexNode n1, RexNode n2) {
      return getRexBuilder().makeCall(SqlStdOperatorTable.PLUS, n1, n2);
    }
...
}
{code}

It would release the need to extend this "class", however it is not clear where local fields should be stored (e.g. private {{Map<RelDataType, RexDynamicParam> dynamicParams;}} and so on)
So I think {{abstract base class}} should be just fine for now.

> RexProgramTest: move "rex building" methods to base class
> ---------------------------------------------------------
>
>                 Key: CALCITE-2462
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2462
>             Project: Calcite
>          Issue Type: Sub-task
>          Components: core
>    Affects Versions: 1.17.0
>            Reporter: Vladimir Sitnikov
>            Assignee: Julian Hyde
>            Priority: Major
>
> RexProgramTest is quite big (2000 lines now), and "easy to use" rex building is useful for many tests.
> So I suggest to move methods like {{gt}}, {{lt}}, etc to the base class, so multiple other tests can reuse it.
> Alternative option would be to use Kotlin for builders, yet I think Java tests will be there for quite a while, so it would be nice to simplify them as well.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)