Class RelBuilderExample


  • public class RelBuilderExample
    extends java.lang.Object
    Example that uses RelBuilder to create various relational expressions.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean verbose  
    • Constructor Summary

      Constructors 
      Constructor Description
      RelBuilderExample​(boolean verbose)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private org.apache.calcite.tools.RelBuilder doExample​(org.apache.calcite.tools.RelBuilder builder, int i)  
      private org.apache.calcite.tools.RelBuilder example0​(org.apache.calcite.tools.RelBuilder builder)
      Creates a relational expression for a table scan.
      private org.apache.calcite.tools.RelBuilder example1​(org.apache.calcite.tools.RelBuilder builder)
      Creates a relational expression for a table scan.
      private org.apache.calcite.tools.RelBuilder example2​(org.apache.calcite.tools.RelBuilder builder)
      Creates a relational expression for a table scan and project.
      private org.apache.calcite.tools.RelBuilder example3​(org.apache.calcite.tools.RelBuilder builder)
      Creates a relational expression for a table scan, aggregate, filter.
      private org.apache.calcite.tools.RelBuilder example4​(org.apache.calcite.tools.RelBuilder builder)
      Sometimes the stack becomes so deeply nested it gets confusing.
      static void main​(java.lang.String[] args)  
      void runAllExamples()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • verbose

        private final boolean verbose
    • Constructor Detail

      • RelBuilderExample

        public RelBuilderExample​(boolean verbose)
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
      • runAllExamples

        public void runAllExamples()
      • doExample

        private org.apache.calcite.tools.RelBuilder doExample​(org.apache.calcite.tools.RelBuilder builder,
                                                              int i)
      • example0

        private org.apache.calcite.tools.RelBuilder example0​(org.apache.calcite.tools.RelBuilder builder)
        Creates a relational expression for a table scan. It is equivalent to
        SELECT *
         FROM emp
      • example1

        private org.apache.calcite.tools.RelBuilder example1​(org.apache.calcite.tools.RelBuilder builder)
        Creates a relational expression for a table scan. It is equivalent to
        SELECT *
         FROM emp
      • example2

        private org.apache.calcite.tools.RelBuilder example2​(org.apache.calcite.tools.RelBuilder builder)
        Creates a relational expression for a table scan and project. It is equivalent to
        SELECT deptno, ename
         FROM emp
      • example3

        private org.apache.calcite.tools.RelBuilder example3​(org.apache.calcite.tools.RelBuilder builder)
        Creates a relational expression for a table scan, aggregate, filter. It is equivalent to
        SELECT deptno, count(*) AS c, sum(sal) AS s
         FROM emp
         GROUP BY deptno
         HAVING count(*) > 10
      • example4

        private org.apache.calcite.tools.RelBuilder example4​(org.apache.calcite.tools.RelBuilder builder)
        Sometimes the stack becomes so deeply nested it gets confusing. To keep things straight, you can remove expressions from the stack. For example, here we are building a bushy join:
                        join
                      /      \
                 join          join
               /      \      /      \
         CUSTOMERS ORDERS LINE_ITEMS PRODUCTS
         

        We build it in three stages. Store the intermediate results in variables `left` and `right`, and use `push()` to put them back on the stack when it is time to create the final `Join`.