Search in sources :

Example 76 with CorrelationId

use of org.apache.calcite.rel.core.CorrelationId in project flink-mirror by flink-ci.

the class HiveParserRexNodeConverter method convertColumn.

private RexNode convertColumn(ExprNodeColumnDesc col) throws SemanticException {
    // if this is co-rrelated we need to make RexCorrelVariable(with id and type)
    // id and type should be retrieved from outerRR
    InputCtx ic = getInputCtx(col);
    if (ic == null) {
        // we have correlated column, build data type from outer rr
        RelDataType rowType = HiveParserTypeConverter.getType(cluster, this.outerRR, null);
        if (this.outerNameToPos.get(col.getColumn()) == null) {
            throw new SemanticException("Invalid column name " + col.getColumn());
        }
        int pos = this.outerNameToPos.get(col.getColumn());
        CorrelationId colCorr = new CorrelationId(this.correlatedId);
        RexNode corExpr = cluster.getRexBuilder().makeCorrel(rowType, colCorr);
        return cluster.getRexBuilder().makeFieldAccess(corExpr, pos);
    }
    int pos = ic.hiveNameToPosMap.get(col.getColumn());
    return cluster.getRexBuilder().makeInputRef(ic.calciteInpDataType.getFieldList().get(pos).getType(), pos + ic.offsetInCalciteSchema);
}
Also used : RelDataType(org.apache.calcite.rel.type.RelDataType) CorrelationId(org.apache.calcite.rel.core.CorrelationId) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException) RexNode(org.apache.calcite.rex.RexNode)

Aggregations

CorrelationId (org.apache.calcite.rel.core.CorrelationId)74 RelNode (org.apache.calcite.rel.RelNode)39 RexNode (org.apache.calcite.rex.RexNode)33 RelDataType (org.apache.calcite.rel.type.RelDataType)25 ArrayList (java.util.ArrayList)22 RelOptCluster (org.apache.calcite.plan.RelOptCluster)19 RexBuilder (org.apache.calcite.rex.RexBuilder)18 RelBuilder (org.apache.calcite.tools.RelBuilder)17 ImmutableBitSet (org.apache.calcite.util.ImmutableBitSet)15 ImmutableList (com.google.common.collect.ImmutableList)12 RelTraitSet (org.apache.calcite.plan.RelTraitSet)12 RexCorrelVariable (org.apache.calcite.rex.RexCorrelVariable)11 RexShuttle (org.apache.calcite.rex.RexShuttle)11 RelDataTypeFactory (org.apache.calcite.rel.type.RelDataTypeFactory)10 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)10 List (java.util.List)9 RelOptUtil (org.apache.calcite.plan.RelOptUtil)9 JoinRelType (org.apache.calcite.rel.core.JoinRelType)9 ByteString (org.apache.calcite.avatica.util.ByteString)7 SqlOperator (org.apache.calcite.sql.SqlOperator)7