Search in sources :

Example 1 with SemiJoinOp

use of herddb.model.planner.SemiJoinOp in project herddb by diennea.

the class CalcitePlanner method planEnumerableSemiJoin.

private PlannerOp planEnumerableSemiJoin(EnumerableSemiJoin op, RelDataType rowType) {
    // please note that EnumerableSemiJoin has a condition field which actually is not useful
    PlannerOp left = convertRelNode(op.getLeft(), null, false);
    PlannerOp right = convertRelNode(op.getRight(), null, false);
    int[] leftKeys = op.getLeftKeys().toIntArray();
    int[] rightKeys = op.getRightKeys().toIntArray();
    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 SemiJoinOp(fieldNames, columns, leftKeys, left, rightKeys, right);
}
Also used : RelDataTypeField(org.apache.calcite.rel.type.RelDataTypeField) PlannerOp(herddb.model.planner.PlannerOp) Column(herddb.model.Column) RelDataType(org.apache.calcite.rel.type.RelDataType) SemiJoinOp(herddb.model.planner.SemiJoinOp)

Example 2 with SemiJoinOp

use of herddb.model.planner.SemiJoinOp in project herddb by diennea.

the class CalcitePlanner method planEnumerableHashJoin.

private PlannerOp planEnumerableHashJoin(EnumerableHashJoin op, RelDataType rowType) {
    // please note that EnumerableSemiJoin 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;
    }
    if (op.isSemiJoin()) {
        return new SemiJoinOp(fieldNames, columns, leftKeys, left, rightKeys, right);
    } else {
        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) SemiJoinOp(herddb.model.planner.SemiJoinOp) 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

Column (herddb.model.Column)2 PlannerOp (herddb.model.planner.PlannerOp)2 SemiJoinOp (herddb.model.planner.SemiJoinOp)2 RelDataType (org.apache.calcite.rel.type.RelDataType)2 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)2 JoinOp (herddb.model.planner.JoinOp)1 NestedLoopJoinOp (herddb.model.planner.NestedLoopJoinOp)1 CompiledSQLExpression (herddb.sql.expressions.CompiledSQLExpression)1 JoinInfo (org.apache.calcite.rel.core.JoinInfo)1