gustavodemorais commented on code in PR #26647: URL: https://github.com/apache/flink/pull/26647#discussion_r2134707701
########## flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/stream/StreamExecMultiJoin.java: ########## @@ -0,0 +1,444 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.table.planner.plan.nodes.exec.stream; + +import org.apache.flink.FlinkVersion; +import org.apache.flink.api.dag.Transformation; +import org.apache.flink.api.java.functions.KeySelector; +import org.apache.flink.configuration.ReadableConfig; +import org.apache.flink.streaming.api.operators.AbstractStreamOperatorFactory; +import org.apache.flink.streaming.api.operators.StreamOperator; +import org.apache.flink.streaming.api.operators.StreamOperatorFactory; +import org.apache.flink.streaming.api.operators.StreamOperatorParameters; +import org.apache.flink.table.data.RowData; +import org.apache.flink.table.planner.delegation.PlannerBase; +import org.apache.flink.table.planner.plan.nodes.exec.ExecEdge; +import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeBase; +import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeConfig; +import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeContext; +import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeMetadata; +import org.apache.flink.table.planner.plan.nodes.exec.InputProperty; +import org.apache.flink.table.planner.plan.nodes.exec.SingleTransformationTranslator; +import org.apache.flink.table.planner.plan.nodes.exec.StateMetadata; +import org.apache.flink.table.planner.plan.nodes.exec.utils.ExecNodeUtil; +import org.apache.flink.table.planner.plan.nodes.exec.utils.TransformationMetadata; +import org.apache.flink.table.planner.plan.utils.JoinUtil; +import org.apache.flink.table.runtime.generated.GeneratedJoinCondition; +import org.apache.flink.table.runtime.generated.JoinCondition; +import org.apache.flink.table.runtime.generated.MultiJoinCondition; +import org.apache.flink.table.runtime.operators.join.stream.StreamingMultiJoinOperator; +import org.apache.flink.table.runtime.operators.join.stream.StreamingMultiJoinOperator.JoinType; +import org.apache.flink.table.runtime.operators.join.stream.keyselector.AttributeBasedJoinKeyExtractor; +import org.apache.flink.table.runtime.operators.join.stream.keyselector.JoinKeyExtractor; +import org.apache.flink.table.runtime.operators.join.stream.utils.JoinInputSideSpec; +import org.apache.flink.table.runtime.typeutils.InternalTypeInfo; +import org.apache.flink.table.types.logical.RowType; + +import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator; +import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonInclude; +import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty; + +import org.apache.calcite.rex.RexNode; +import org.checkerframework.checker.nullness.qual.Nullable; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import static org.apache.flink.util.Preconditions.checkArgument; +import static org.apache.flink.util.Preconditions.checkNotNull; + +/** + * Stream {@link StreamExecNode} for N-way Joins. This node handles multi-way joins in streaming + * mode, supporting different join types and conditions for each input. + */ +@ExecNodeMetadata( + name = "stream-exec-multi-join", + version = 1, + producedTransformations = StreamExecMultiJoin.MULTI_JOIN_TRANSFORMATION, + minPlanVersion = FlinkVersion.v2_0, + minStateVersion = FlinkVersion.v2_0) +public class StreamExecMultiJoin extends ExecNodeBase<RowData> + implements StreamExecNode<RowData>, SingleTransformationTranslator<RowData> { + + public static final String MULTI_JOIN_TRANSFORMATION = "multi-join"; + + // Field names for JSON serialization + private static final String FIELD_NAME_ID = "id"; + private static final String FIELD_NAME_TYPE = "type"; + private static final String FIELD_NAME_CONFIGURATION = "configuration"; + private static final String FIELD_NAME_INPUT_PROPERTIES = "inputProperties"; + private static final String FIELD_NAME_OUTPUT_TYPE = "outputType"; + private static final String FIELD_NAME_DESCRIPTION = "description"; + private static final String FIELD_NAME_JOIN_TYPES = "joinTypes"; + private static final String FIELD_NAME_JOIN_CONDITIONS = "joinConditions"; + private static final String FIELD_NAME_GENERATED_MULTI_JOIN_CONDITION = + "generatedMultiJoinCondition"; + private static final String FIELD_NAME_JOIN_ATTRIBUTE_MAP = "joinAttributeMap"; + private static final String FIELD_NAME_INPUT_SIDE_SPECS = "inputSideSpecs"; + private static final String FIELD_NAME_STATE_METADATA_LIST = "stateMetadataList"; + private static final String FIELD_NAME_KEY_SELECTORS = "keySelectorsForTransformation"; + private static final String FIELD_NAME_COMMON_KEY_TYPE = "commonKeyType"; + + @JsonProperty(FIELD_NAME_JOIN_TYPES) + private final List<JoinType> joinTypes; + + @JsonProperty(FIELD_NAME_JOIN_CONDITIONS) + private final List<? extends @Nullable RexNode> joinConditions; + + @JsonProperty(FIELD_NAME_JOIN_ATTRIBUTE_MAP) + private final Map< + Integer, + Map< + AttributeBasedJoinKeyExtractor.AttributeRef, + AttributeBasedJoinKeyExtractor.AttributeRef>> + joinAttributeMap; + + @JsonProperty(FIELD_NAME_INPUT_SIDE_SPECS) + private final List<JoinInputSideSpec> inputSideSpecs; + + @JsonProperty(FIELD_NAME_KEY_SELECTORS) + private final List<KeySelector<RowData, RowData>> commonJoinKeySelectorsForTransformation; + + @JsonProperty(FIELD_NAME_COMMON_KEY_TYPE) + private final InternalTypeInfo<RowData> commonJoinKeyType; + + @JsonProperty(FIELD_NAME_STATE_METADATA_LIST) + @JsonInclude(JsonInclude.Include.NON_NULL) + private final List<StateMetadata> stateMetadataList; + + public StreamExecMultiJoin( + ReadableConfig tableConfig, + List<JoinType> joinTypes, + List<? extends @Nullable RexNode> joinConditions, + @Nullable RexNode generatedMultiJoinCondition, + Map< + Integer, + Map< + AttributeBasedJoinKeyExtractor.AttributeRef, + AttributeBasedJoinKeyExtractor.AttributeRef>> + joinAttributeMap, + List<JoinInputSideSpec> inputSideSpecs, + Map<Integer, Long> stateTtlFromHint, + List<InputProperty> inputProperties, + RowType outputType, + String description, + List<KeySelector<RowData, RowData>> commonJoinKeySelectorsForTransformation, + InternalTypeInfo<RowData> commonJoinKeyType) { Review Comment: done -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org