Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4.0-incubating
    • Component/s: None
    • Labels:
      None

      Description

      Creating relational expressions currently involves calling the "create" method of the relevant sub-class of RelNode, often with a lot of obscure parameters. This might be appropriate for someone writing a rule, but is not particularly friendly to someone who wants to write queries using an API.

      We propose instead a builder. It would have a method for each core type of relational expression; for example a filter method that returns a Filter. For a given type, there might be overloads that allow you more control.

      Inside the builder is a factory for each operator type. Thus a builder could be configured to create logical rels (LogicalFilter, LogicalProject) or rels of a different convention (HiveFilter, HiveProject).

      Two particular areas that the builder can help. First, it can deduce the names and types of output columns. (You can override types, and optionally also names, or maybe just some names, using other APIs.)

      Second, it can help you build RexNode expressions. It knows the type and names of the input, it will let you build expressions in terms of column ordinals or names, which are easier than RexInputRefs.

        Activity

        Hide
        julianhyde Julian Hyde added a comment -

        It's looking good – a 5 line SQL statement becomes not much more than 5 lines of Java in many cases.

        I've deployed a preview of the manual to http://calcite.hydromatic.net/docs/algebra.html, and javadoc to http://calcite.hydromatic.net/apidocs/org/apache/calcite/tools/RelBuilder.html. The code is in my 748-builder branch, https://github.com/julianhyde/incubator-calcite/tree/748-builder.

        Show
        julianhyde Julian Hyde added a comment - It's looking good – a 5 line SQL statement becomes not much more than 5 lines of Java in many cases. I've deployed a preview of the manual to http://calcite.hydromatic.net/docs/algebra.html , and javadoc to http://calcite.hydromatic.net/apidocs/org/apache/calcite/tools/RelBuilder.html . The code is in my 748-builder branch, https://github.com/julianhyde/incubator-calcite/tree/748-builder .
        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/6609cb1a .
        Hide
        jnadeau Jacques Nadeau added a comment -

        Resolved in release 1.4.0-incubating (2015-08-23)

        Show
        jnadeau Jacques Nadeau added a comment - Resolved in release 1.4.0-incubating (2015-08-23)

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            julianhyde Julian Hyde
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development