use of com.hazelcast.jet.sql.impl.opt.logical.JoinLogicalRel in project hazelcast by hazelcast.
the class JoinPhysicalRule method onMatch.
@Override
public void onMatch(RelOptRuleCall call) {
JoinLogicalRel logicalJoin = call.rel(0);
JoinRelType joinType = logicalJoin.getJoinType();
if (joinType != JoinRelType.INNER && joinType != JoinRelType.LEFT) {
throw new RuntimeException("Unexpected joinType: " + joinType);
}
RelNode leftInput = call.rel(1);
RelNode rightInput = call.rel(2);
if (OptUtils.isUnbounded(rightInput)) {
// can be on the left side.
return;
}
RelNode leftInputConverted = RelRule.convert(leftInput, leftInput.getTraitSet().replace(PHYSICAL));
RelNode rightInputConverted = RelRule.convert(rightInput, rightInput.getTraitSet().replace(PHYSICAL));
// we don't use hash join for unbounded left input because it doesn't refresh the right side
if (OptUtils.isBounded(leftInput)) {
RelNode rel = new JoinHashPhysicalRel(logicalJoin.getCluster(), logicalJoin.getTraitSet().replace(PHYSICAL), leftInputConverted, rightInputConverted, logicalJoin.getCondition(), logicalJoin.getJoinType());
call.transformTo(rel);
}
if (rightInput instanceof TableScan) {
HazelcastTable rightHzTable = rightInput.getTable().unwrap(HazelcastTable.class);
if (SqlConnectorUtil.getJetSqlConnector(rightHzTable.getTarget()).isNestedLoopReaderSupported()) {
RelNode rel2 = new JoinNestedLoopPhysicalRel(logicalJoin.getCluster(), OptUtils.toPhysicalConvention(logicalJoin.getTraitSet()), leftInputConverted, rightInputConverted, logicalJoin.getCondition(), logicalJoin.getJoinType());
call.transformTo(rel2);
}
}
}
Aggregations