lincoln-lil commented on code in PR #20324:
URL: https://github.com/apache/flink/pull/20324#discussion_r939876601
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/common/CommonExecLookupJoin.java:
##########
@@ -329,8 +342,66 @@ private Transformation<RowData>
createSyncLookupJoinWithState(
isLeftOuterJoin,
isObjectReuseEnabled);
- // TODO then wrapper it into a keyed lookup function with state
FLINK-28568
- throw new UnsupportedOperationException("to be supported");
+ RowType rightRowType =
+ getRightRowType(
+ getProjectionRowTypeOnTemporalTable(relBuilder),
tableSourceRowType);
+
+ KeyedLookupJoinWrapper keyedLookupJoinWrapper =
+ new KeyedLookupJoinWrapper(
+ (LookupJoinRunner) processFunction,
+ StateConfigUtil.createTtlConfig(
+
config.get(ExecutionConfigOptions.IDLE_STATE_RETENTION).toMillis()),
+ InternalSerializers.create(rightRowType),
+ lookupKeyContainsPrimaryKey);
+
+ KeyedProcessOperator<RowData, RowData, RowData> operator =
+ new KeyedProcessOperator<>(keyedLookupJoinWrapper);
+
+ List<Integer> refKeys =
+ allLookupKeys.values().stream()
+ .filter(key -> key instanceof
LookupJoinUtil.FieldRefLookupKey)
+ .map(key -> ((LookupJoinUtil.FieldRefLookupKey)
key).index)
+ .collect(Collectors.toList());
+ RowDataKeySelector keySelector;
+
+ // use single parallelism for empty key shuffle
+ boolean singleParallelism = refKeys.isEmpty();
+ if (singleParallelism) {
+ // all lookup keys are constants, then use an empty key selector
+ keySelector = EmptyRowDataKeySelector.INSTANCE;
+ } else {
+ // make it a deterministic asc order
+ Collections.sort(refKeys);
+ keySelector =
+ KeySelectorUtil.getRowDataSelector(
+ classLoader,
+
refKeys.stream().mapToInt(Integer::intValue).toArray(),
+ InternalTypeInfo.of(inputRowType));
+ }
+ final KeyGroupStreamPartitioner<RowData, RowData> partitioner =
+ new KeyGroupStreamPartitioner<>(
+ keySelector,
KeyGroupRangeAssignment.DEFAULT_LOWER_BOUND_MAX_PARALLELISM);
+ Transformation<RowData> partitionedTransform =
+ new PartitionTransformation<>(inputTransformation,
partitioner);
+ if (singleParallelism) {
+ setSingletonParallelism(partitionedTransform);
+ } else {
+
partitionedTransform.setParallelism(inputTransformation.getParallelism());
+ }
+
+ OneInputTransformation<RowData, RowData> transform =
+ ExecNodeUtil.createOneInputTransformation(
+ partitionedTransform,
+
createTransformationMeta(LOOKUP_JOIN_WITH_STATE_TRANSFORMATION, config),
+ operator,
+ InternalTypeInfo.of(resultRowType),
+ partitionedTransform.getParallelism());
+ transform.setStateKeySelector(keySelector);
+ transform.setStateKeyType(keySelector.getProducedType());
+ if (singleParallelism) {
+ setSingletonParallelism(transform);
+ }
+ return transform;
}
private LogicalType getLookupKeyLogicalType(
Review Comment:
Yes, this newly method from master is unused, I'll remove it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]