use of com.hazelcast.jet.sql.impl.JetJoinInfo in project hazelcast by hazelcast.
the class CreateDagVisitor method onHashJoin.
public Vertex onHashJoin(JoinHashPhysicalRel rel) {
JetJoinInfo joinInfo = rel.joinInfo(parameterMetadata);
Vertex joinVertex = dag.newUniqueVertex("Hash Join", SqlHashJoinP.supplier(joinInfo, rel.getRight().getRowType().getFieldCount()));
connectJoinInput(joinInfo, rel.getLeft(), rel.getRight(), joinVertex);
return joinVertex;
}
use of com.hazelcast.jet.sql.impl.JetJoinInfo in project hazelcast by hazelcast.
the class JoinNestedLoopPhysicalRel method joinInfo.
public JetJoinInfo joinInfo(QueryParameterMetadata parameterMetadata) {
List<Integer> leftKeys = analyzeCondition().leftKeys.toIntegerList();
List<Integer> rightKeys = analyzeCondition().rightKeys.toIntegerList();
HazelcastTable table = OptUtils.extractHazelcastTable(getRight());
RexBuilder rexBuilder = getCluster().getRexBuilder();
List<RexNode> additionalNonEquiConditions = new ArrayList<>();
for (int i = 0; i < rightKeys.size(); i++) {
Integer rightKeyIndex = rightKeys.get(i);
RexNode rightExpr = table.getProjects().get(rightKeyIndex);
if (rightExpr instanceof RexInputRef) {
rightKeys.set(i, ((RexInputRef) rightExpr).getIndex());
} else {
// offset the indices in rightExp by the width of left row
rightExpr = rightExpr.accept(new RexShuttle() {
@Override
public RexNode visitInputRef(RexInputRef inputRef) {
return rexBuilder.makeInputRef(inputRef.getType(), inputRef.getIndex() + getLeft().getRowType().getFieldCount());
}
});
additionalNonEquiConditions.add(rexBuilder.makeCall(HazelcastSqlOperatorTable.EQUALS, rexBuilder.makeInputRef(getLeft(), leftKeys.get(i)), rightExpr));
leftKeys.remove(i);
rightKeys.remove(i);
i--;
}
}
Expression<Boolean> nonEquiCondition = filter(schema(parameterMetadata), RexUtil.composeConjunction(rexBuilder, asList(analyzeCondition().getRemaining(rexBuilder), RexUtil.composeConjunction(rexBuilder, additionalNonEquiConditions))), parameterMetadata);
Expression<Boolean> condition = filter(schema(parameterMetadata), getCondition(), parameterMetadata);
return new JetJoinInfo(getJoinType(), toIntArray(leftKeys), toIntArray(rightKeys), nonEquiCondition, condition);
}
use of com.hazelcast.jet.sql.impl.JetJoinInfo in project hazelcast by hazelcast.
the class JoinByEquiJoinProcessorTest method runTest.
private void runTest(JoinRelType joinType, Expression<Boolean> rowProjectorCondition, Expression<?> rowProjectorProjection, Expression<Boolean> nonEquiCondition, List<JetSqlRow> input, List<JetSqlRow> output) {
KvRowProjector.Supplier projectorSupplier = KvRowProjector.supplier(new QueryPath[] { QueryPath.KEY_PATH, QueryPath.VALUE_PATH }, new QueryDataType[] { QueryDataType.INT, VARCHAR }, GenericQueryTargetDescriptor.DEFAULT, GenericQueryTargetDescriptor.DEFAULT, rowProjectorCondition, singletonList(rowProjectorProjection));
ProcessorMetaSupplier processor = JoinByEquiJoinProcessorSupplier.supplier(new JetJoinInfo(joinType, new int[] { 0 }, new int[] { 0 }, nonEquiCondition, null), MAP_NAME, projectorSupplier);
TestSupport.verifyProcessor(adaptSupplier(processor)).jobConfig(new JobConfig().setArgument(SQL_ARGUMENTS_KEY_NAME, emptyList())).input(input).hazelcastInstance(instance()).outputChecker(SqlTestSupport::compareRowLists).disableProgressAssertion().expectOutput(output);
}
use of com.hazelcast.jet.sql.impl.JetJoinInfo in project hazelcast by hazelcast.
the class JoinScanProcessorTest method runTest.
private void runTest(JoinRelType joinType, Expression<Boolean> rowProjectorCondition, List<Expression<?>> rowProjectorProjections, Expression<Boolean> condition, List<JetSqlRow> input, List<JetSqlRow> output) {
KvRowProjector.Supplier projectorSupplier = KvRowProjector.supplier(new QueryPath[] { QueryPath.KEY_PATH, QueryPath.VALUE_PATH }, new QueryDataType[] { INT, VARCHAR }, GenericQueryTargetDescriptor.DEFAULT, GenericQueryTargetDescriptor.DEFAULT, rowProjectorCondition, rowProjectorProjections);
JoinScanProcessorSupplier processor = new JoinScanProcessorSupplier(new JetJoinInfo(joinType, new int[] { 0 }, new int[] { 0 }, null, condition), MAP_NAME, projectorSupplier);
TestSupport.verifyProcessor(adaptSupplier(processor)).jobConfig(new JobConfig().setArgument(SQL_ARGUMENTS_KEY_NAME, emptyList())).input(input).hazelcastInstance(instance()).outputChecker(SqlTestSupport::compareRowLists).disableProgressAssertion().expectOutput(output);
}
use of com.hazelcast.jet.sql.impl.JetJoinInfo in project hazelcast by hazelcast.
the class SqlHashJoinPTest method runTest.
private void runTest(JoinRelType joinType, Expression<Boolean> nonEquiCondition, int rightInputColumnCount, int[] leftEquiJoinIndices, int[] rightEquiJoinIndices, List<JetSqlRow> leftInput, List<JetSqlRow> rightInput, List<JetSqlRow> output) {
ProcessorSupplier processor = SqlHashJoinP.supplier(new JetJoinInfo(joinType, leftEquiJoinIndices, rightEquiJoinIndices, nonEquiCondition, null), rightInputColumnCount);
TestSupport.verifyProcessor(adaptSupplier(processor)).jobConfig(new JobConfig().setArgument(SQL_ARGUMENTS_KEY_NAME, emptyList())).inputs(asList(leftInput, rightInput), new int[] { LOW_PRIORITY, HIGH_PRIORITY }).hazelcastInstance(instance()).outputChecker(SqlTestSupport::compareRowLists).disableSnapshots().expectOutput(output);
}
Aggregations