Search in sources :

Example 21 with JoinInfo

use of org.apache.calcite.rel.core.JoinInfo in project herddb by diennea.

the class CalcitePlanner method planEnumerableJoin.

private PlannerOp planEnumerableJoin(EnumerableHashJoin op, RelDataType rowType) {
    // please note that EnumerableJoin has a condition field which actually is not useful
    PlannerOp left = convertRelNode(op.getLeft(), null, false, false);
    PlannerOp right = convertRelNode(op.getRight(), null, false, false);
    final JoinInfo analyzeCondition = op.analyzeCondition();
    int[] leftKeys = analyzeCondition.leftKeys.toIntArray();
    int[] rightKeys = analyzeCondition.rightKeys.toIntArray();
    boolean generateNullsOnLeft = op.getJoinType().generatesNullsOnLeft();
    boolean generateNullsOnRight = op.getJoinType().generatesNullsOnRight();
    List<CompiledSQLExpression> nonEquiConditions = convertJoinNonEquiConditions(analyzeCondition);
    final RelDataType _rowType = rowType == null ? op.getRowType() : rowType;
    List<RelDataTypeField> fieldList = _rowType.getFieldList();
    Column[] columns = new Column[fieldList.size()];
    String[] fieldNames = new String[columns.length];
    int i = 0;
    for (RelDataTypeField field : fieldList) {
        Column col = Column.column(field.getName().toLowerCase(), convertToHerdType(field.getType()));
        fieldNames[i] = col.name;
        columns[i++] = col;
    }
    return new JoinOp(fieldNames, columns, leftKeys, left, rightKeys, right, generateNullsOnLeft, generateNullsOnRight, false, nonEquiConditions);
}
Also used : PlannerOp(herddb.model.planner.PlannerOp) CompiledSQLExpression(herddb.sql.expressions.CompiledSQLExpression) RelDataType(org.apache.calcite.rel.type.RelDataType) JoinInfo(org.apache.calcite.rel.core.JoinInfo) RelDataTypeField(org.apache.calcite.rel.type.RelDataTypeField) Column(herddb.model.Column) JoinOp(herddb.model.planner.JoinOp) SemiJoinOp(herddb.model.planner.SemiJoinOp) NestedLoopJoinOp(herddb.model.planner.NestedLoopJoinOp)

Aggregations

JoinInfo (org.apache.calcite.rel.core.JoinInfo)21 RelNode (org.apache.calcite.rel.RelNode)12 ImmutableBitSet (org.apache.calcite.util.ImmutableBitSet)8 Join (org.apache.calcite.rel.core.Join)7 ArrayList (java.util.ArrayList)6 RexNode (org.apache.calcite.rex.RexNode)6 RelOptCluster (org.apache.calcite.plan.RelOptCluster)5 LogicalJoin (org.apache.calcite.rel.logical.LogicalJoin)5 RelDataType (org.apache.calcite.rel.type.RelDataType)5 Project (org.apache.calcite.rel.core.Project)4 RelMetadataQuery (org.apache.calcite.rel.metadata.RelMetadataQuery)4 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)4 Column (herddb.model.Column)3 JoinOp (herddb.model.planner.JoinOp)3 NestedLoopJoinOp (herddb.model.planner.NestedLoopJoinOp)3 PlannerOp (herddb.model.planner.PlannerOp)3 SemiJoinOp (herddb.model.planner.SemiJoinOp)3 CompiledSQLExpression (herddb.sql.expressions.CompiledSQLExpression)3 HepRelVertex (org.apache.calcite.plan.hep.HepRelVertex)3 InvalidRelException (org.apache.calcite.rel.InvalidRelException)3