Class PigRelBuilder

java.lang.Object
org.apache.calcite.tools.RelBuilder
org.apache.calcite.piglet.PigRelBuilder

public class PigRelBuilder extends RelBuilder
Extension to RelBuilder for Pig logical operators.
  • Method Details

    • create

      public static PigRelBuilder create(FrameworkConfig config)
      Creates a PigRelBuilder.
    • getRel

      public RelNode getRel(String alias)
    • getRel

      public RelNode getRel(org.apache.pig.newplan.Operator pig)
    • getAlias

      public String getAlias()
    • clear

      public void clear()
      Description copied from class: RelBuilder
      Clears the stack.

      The builder's state is now the same as when it was created.

      Overrides:
      clear in class RelBuilder
    • checkMap

      public boolean checkMap(org.apache.pig.newplan.logical.relational.LogicalRelationalOperator pigOp)
      Checks if a Pig logical operator has been translated before. If it has, push the corresponding relational algebra operator on top instead of doing the translation work again.
      Parameters:
      pigOp - The Pig logical operator to check.
      Returns:
      true iff the pigOp has been processed before.
    • updateAlias

      public void updateAlias(org.apache.pig.newplan.Operator pigOp, String alias, boolean updatePigRelMap)
      Updates the Pig logical operator and its alias with the top relational algebra node.
      Parameters:
      pigOp - the Pig logical operator
      alias - the alias
      updatePigRelMap - whether to update the PigRelMap
    • scan

      public RelBuilder scan(RelOptTable userSchema, String... tableNames)
      Scans a table with its given schema and names.
      Parameters:
      userSchema - The schema of the table to scan
      tableNames - The names of the table to scan
      Returns:
      This builder
    • scan

      public RelBuilder scan(RelDataType rowType, String... tableNames)
      Makes a table scan operator for a given row type and names.
      Parameters:
      rowType - Row type
      tableNames - Table names
      Returns:
      This builder
    • scan

      public RelBuilder scan(RelDataType rowType, List<String> tableNames)
      Makes a table scan operator for a given row type and names.
      Parameters:
      rowType - Row type
      tableNames - Table names
      Returns:
      This builder
    • project

      public RelNode project(RelNode input, RelDataType outputType)
      Projects a specific row type out of a relation algebra operator. For any field in output type, if there is no matching input field, we project null value of the corresponding output field type.

      For example, given:

      • Input rel A with A_type(X: int, Y: varchar)
      • Output type B_type(X: int, Y: varchar, Z: boolean, W: double)

      project(A, B_type) gives new relation C(X: int, Y: varchar, null, null).

      Parameters:
      input - The relation algebra operator to be projected
      outputType - The data type for the projected relation algebra operator
      Returns:
      The projected relation algebra operator
    • cogroup

      public RelBuilder cogroup(Iterable<? extends RelBuilder.GroupKey> groupKeys)
      Cogroups relations on top of the stack. The number of relations and the group key are specified in groupKeys
      Parameters:
      groupKeys - Lists of group keys of relations to be cogrouped.
      Returns:
      This builder
    • multiSetFlatten

      public RelBuilder multiSetFlatten(List<Integer> flattenCols, List<String> flattenOutputAliases)
      Flattens the top relation on provided columns.
      Parameters:
      flattenCols - Indexes of columns to be flattened. These columns should have multiset type.
      Returns:
      This builder
    • multiSetFlatten

      public RelBuilder multiSetFlatten()
      Flattens the top relation will all multiset columns. Call this method only if the top relation contains multiset columns only.
      Returns:
      This builder.
    • correl

      public RexNode correl(List<RelDataTypeField> inputFields, CorrelationId correlId)
      Makes the correlated expression from rel input fields and correlation id.
      Parameters:
      inputFields - Rel input field list
      correlId - Correlation id
      Returns:
      This builder
    • collect

      public RelBuilder collect()
      Collects all rows of the top rel into a single multiset value.
      Returns:
      This builder
    • dot

      public RexNode dot(RexNode node, Object field)
    • literal

      public RexLiteral literal(Object value, RelDataType type)
    • getRelsForStores

      public List<RelNode> getRelsForStores()
      Gets all relational plans corresponding to Pig Store operators.
    • getFields

      public com.google.common.collect.ImmutableList<RexNode> getFields(int inputCount, int inputOrdinal, int fieldOrdinal)
    • compatibleType

      public static boolean compatibleType(RelDataType t1, RelDataType t2)
      Checks if two relational data types are compatible.
      Parameters:
      t1 - first type
      t2 - second type
      Returns:
      true if t1 is compatible with t2