Package org.apache.calcite.piglet
Class PigRelBuilder
java.lang.Object
org.apache.calcite.tools.RelBuilder
org.apache.calcite.piglet.PigRelBuilder
Extension to
RelBuilder
for Pig logical operators.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Context constructed during Pig-to-RelNode
translation process.Nested classes/interfaces inherited from class org.apache.calcite.tools.RelBuilder
RelBuilder.AggCall, RelBuilder.Config, RelBuilder.GroupKey, RelBuilder.OverCall
-
Field Summary
Fields inherited from class org.apache.calcite.tools.RelBuilder
cluster, relOptSchema
-
Method Summary
Modifier and TypeMethodDescriptionboolean
checkMap
(org.apache.pig.newplan.logical.relational.LogicalRelationalOperator pigOp) Checks if a Pig logical operator has been translated before.void
clear()
Clears the stack.cogroup
(Iterable<? extends RelBuilder.GroupKey> groupKeys) Cogroups relations on top of the stack.collect()
Collects all rows of the top rel into a single multiset value.static boolean
compatibleType
(RelDataType t1, RelDataType t2) Checks if two relational data types are compatible.correl
(List<RelDataTypeField> inputFields, CorrelationId correlId) Makes the correlated expression from rel input fields and correlation id.static PigRelBuilder
create
(FrameworkConfig config) Creates a PigRelBuilder.getAlias()
com.google.common.collect.ImmutableList<RexNode>
getFields
(int inputCount, int inputOrdinal, int fieldOrdinal) getRel
(org.apache.pig.newplan.Operator pig) Gets all relational plans corresponding to Pig Store operators.literal
(Object value, RelDataType type) Flattens the top relation will all multiset columns.multiSetFlatten
(List<Integer> flattenCols, List<String> flattenOutputAliases) Flattens the top relation on provided columns.project
(RelNode input, RelDataType outputType) Projects a specific row type out of a relation algebra operator.scan
(RelOptTable userSchema, String... tableNames) Scans a table with its given schema and names.scan
(RelDataType rowType, String... tableNames) Makes a table scan operator for a given row type and names.scan
(RelDataType rowType, List<String> tableNames) Makes a table scan operator for a given row type and names.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.Methods inherited from class org.apache.calcite.tools.RelBuilder
adoptConvention, aggregate, aggregate, aggregate, aggregateCall, aggregateCall, aggregateCall, aggregateCall, aggregateCall, aggregateCall, aggregateCall, aggregateCall, aggregateCall, aggregateCall, aggregateCall, aggregateCall, aggregateRex, aggregateRex, alias, all, and, and, antiJoin, antiJoin, arrayQuery, as, asofJoin, avg, avg, avg, avg, between, build, call, call, cast, cast, cast, cast, cast, cast, convert, correlate, correlate, count, count, count, count, countStar, currentRow, cursor, desc, distinct, dot, dot, empty, equals, exchange, exists, field, field, field, field, field, field, field, field, fields, fields, fields, fields, fields, fields, fields, filter, filter, filter, filter, following, functionScan, functionScan, getCluster, getRelOptSchema, getRexBuilder, getScanFactory, getTypeFactory, greaterThan, greaterThanOrEqual, groupKey, groupKey, groupKey, groupKey, groupKey, groupKey, groupKey, groupKey, groupKey, groupKey, hints, hints, in, in, in, in, intersect, intersect, isDistinctFrom, isNotDistinctFrom, isNotNull, isNull, join, join, join, join, join, lessThan, lessThanOrEqual, let, limit, literal, literalAgg, mapQuery, match, max, max, min, min, minus, minus, multisetQuery, not, notEquals, nullsFirst, nullsLast, or, or, patternAlter, patternAlter, patternConcat, patternConcat, patternExclude, patternField, patternPermute, patternPermute, patternQuantify, patternQuantify, peek, peek, peek, permute, pivot, preceding, project, project, project, project, project, projectExcept, projectExcept, projectNamed, projectNamed, projectPlus, projectPlus, proto, proto, push, pushAll, rename, repeatUnion, repeatUnion, sample, scalarQuery, scan, scan, semiJoin, semiJoin, size, snapshot, some, sort, sort, sort, sort, sortExchange, sortLimit, sortLimit, sortLimit, sum, sum, sum, sum, toString, transform, transientScan, transientScan, unboundedFollowing, unboundedPreceding, uncollect, union, union, unique, unpivot, values, values, values, values, variable, variable, with, withPredicates, withSimplifier
-
Method Details
-
create
Creates a PigRelBuilder. -
getRel
-
getRel
-
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 classRelBuilder
-
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 operatoralias
- the aliasupdatePigRelMap
- whether to update the PigRelMap
-
scan
Scans a table with its given schema and names.- Parameters:
userSchema
- The schema of the table to scantableNames
- The names of the table to scan- Returns:
- This builder
-
scan
Makes a table scan operator for a given row type and names.- Parameters:
rowType
- Row typetableNames
- Table names- Returns:
- This builder
-
scan
Makes a table scan operator for a given row type and names.- Parameters:
rowType
- Row typetableNames
- Table names- Returns:
- This builder
-
project
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
withA_type(X: int, Y: varchar)
- Output type
B_type(X: int, Y: varchar, Z: boolean, W: double)
project(A, B_type)
gives new relationC(X: int, Y: varchar, null, null)
.- Parameters:
input
- The relation algebra operator to be projectedoutputType
- The data type for the projected relation algebra operator- Returns:
- The projected relation algebra operator
- Input rel
-
cogroup
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
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
Flattens the top relation will all multiset columns. Call this method only if the top relation contains multiset columns only.- Returns:
- This builder.
-
correl
Makes the correlated expression from rel input fields and correlation id.- Parameters:
inputFields
- Rel input field listcorrelId
- Correlation id- Returns:
- This builder
-
collect
Collects all rows of the top rel into a single multiset value.- Returns:
- This builder
-
dot
-
literal
-
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
Checks if two relational data types are compatible.- Parameters:
t1
- first typet2
- second type- Returns:
- true if t1 is compatible with t2
-