Search in sources :

Example 1 with OuterJoinType

use of org.apache.flink.api.common.operators.base.OuterJoinOperatorBase.OuterJoinType in project flink by apache.

the class OuterJoinNode method getDataProperties.

private List<OperatorDescriptorDual> getDataProperties() {
    OuterJoinOperatorBase<?, ?, ?, ?> operator = getOperator();
    OuterJoinType type = operator.getOuterJoinType();
    JoinHint joinHint = operator.getJoinHint();
    joinHint = joinHint == null ? JoinHint.OPTIMIZER_CHOOSES : joinHint;
    List<OperatorDescriptorDual> list;
    switch(type) {
        case LEFT:
            list = createLeftOuterJoinDescriptors(joinHint);
            break;
        case RIGHT:
            list = createRightOuterJoinDescriptors(joinHint);
            break;
        case FULL:
            list = createFullOuterJoinDescriptors(joinHint);
            break;
        default:
            throw new CompilerException("Unknown outer join type: " + type);
    }
    Partitioner<?> customPartitioner = operator.getCustomPartitioner();
    if (customPartitioner != null) {
        for (OperatorDescriptorDual desc : list) {
            ((AbstractJoinDescriptor) desc).setCustomPartitioner(customPartitioner);
        }
    }
    return list;
}
Also used : JoinHint(org.apache.flink.api.common.operators.base.JoinOperatorBase.JoinHint) CompilerException(org.apache.flink.optimizer.CompilerException) OperatorDescriptorDual(org.apache.flink.optimizer.operators.OperatorDescriptorDual) AbstractJoinDescriptor(org.apache.flink.optimizer.operators.AbstractJoinDescriptor) OuterJoinType(org.apache.flink.api.common.operators.base.OuterJoinOperatorBase.OuterJoinType)

Example 2 with OuterJoinType

use of org.apache.flink.api.common.operators.base.OuterJoinOperatorBase.OuterJoinType in project flink by apache.

the class AbstractSortMergeOuterJoinIteratorITCase method testFullOuterWithSample.

@SuppressWarnings("unchecked")
protected void testFullOuterWithSample() throws Exception {
    CollectionIterator<Tuple2<String, String>> input1 = CollectionIterator.of(new Tuple2<>("Jack", "Engineering"), new Tuple2<>("Tim", "Sales"), new Tuple2<>("Zed", "HR"));
    CollectionIterator<Tuple2<String, Integer>> input2 = CollectionIterator.of(new Tuple2<>("Allison", 100), new Tuple2<>("Jack", 200), new Tuple2<>("Zed", 150), new Tuple2<>("Zed", 250));
    OuterJoinType outerJoinType = OuterJoinType.FULL;
    List<Tuple4<String, String, String, Object>> actual = computeOuterJoin(input1, input2, outerJoinType);
    List<Tuple4<String, String, String, Object>> expected = Arrays.asList(new Tuple4<String, String, String, Object>(null, null, "Allison", 100), new Tuple4<String, String, String, Object>("Jack", "Engineering", "Jack", 200), new Tuple4<String, String, String, Object>("Tim", "Sales", null, null), new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 150), new Tuple4<String, String, String, Object>("Zed", "HR", "Zed", 250));
    Assert.assertEquals(expected, actual);
}
Also used : Tuple4(org.apache.flink.api.java.tuple.Tuple4) Tuple2(org.apache.flink.api.java.tuple.Tuple2) OuterJoinType(org.apache.flink.api.common.operators.base.OuterJoinOperatorBase.OuterJoinType)

Aggregations

OuterJoinType (org.apache.flink.api.common.operators.base.OuterJoinOperatorBase.OuterJoinType)2 JoinHint (org.apache.flink.api.common.operators.base.JoinOperatorBase.JoinHint)1 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)1 Tuple4 (org.apache.flink.api.java.tuple.Tuple4)1 CompilerException (org.apache.flink.optimizer.CompilerException)1 AbstractJoinDescriptor (org.apache.flink.optimizer.operators.AbstractJoinDescriptor)1 OperatorDescriptorDual (org.apache.flink.optimizer.operators.OperatorDescriptorDual)1