You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "xuyangzhong (via GitHub)" <gi...@apache.org> on 2026/03/25 11:11:36 UTC

[PR] [FLINK-39233][table-runtime] Support cascaded delta join runtime [flink]

xuyangzhong opened a new pull request, #27828:
URL: https://github.com/apache/flink/pull/27828

   ## What is the purpose of the change
   
   Support cascaded delta join runtime.
   
   Note: Considering the PR size, the restore test for cascaded delta join will be introduced in a separate PR later(https://issues.apache.org/jira/browse/FLINK-39322).
   
   ## Brief change log
   
     - *Introduce `CascadedLookupHandler` and `TailOutputDataHandler` for cascaded delta join lookup chain*
     - *Add operator test and IT cases to verify this pr*
   
   ## Verifying this change
   
   Tests are added to verify this pr.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? 
   


-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39233][table-runtime] Support cascaded delta join runtime [flink]

Posted by "xuyangzhong (via GitHub)" <gi...@apache.org>.
xuyangzhong merged PR #27828:
URL: https://github.com/apache/flink/pull/27828


-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39233][table-runtime] Support cascaded delta join runtime [flink]

Posted by "xuyangzhong (via GitHub)" <gi...@apache.org>.
xuyangzhong commented on PR #27828:
URL: https://github.com/apache/flink/pull/27828#issuecomment-4132044933

   > @xuyangzhong Overall looks good! I left some minor comments there.
   > 
   > Btw, can you add extra boundary tests, e.g., using empty dimension table / null value as join key.
   
   Sure. Tests with `1. join keys contain null 2. empty table` are added.


-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39233][table-runtime] Support cascaded delta join runtime [flink]

Posted by "lincoln-lil (via GitHub)" <gi...@apache.org>.
lincoln-lil commented on code in PR #27828:
URL: https://github.com/apache/flink/pull/27828#discussion_r2992082756


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/join/deltajoin/CascadedLookupHandler.java:
##########
@@ -0,0 +1,322 @@
+/*
+ * 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.runtime.operators.join.deltajoin;
+
+import org.apache.flink.api.common.functions.FlatMapFunction;
+import org.apache.flink.api.common.functions.OpenContext;
+import org.apache.flink.api.common.functions.RuntimeContext;
+import org.apache.flink.api.common.functions.util.FunctionUtils;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.utils.JoinedRowData;
+import org.apache.flink.table.runtime.generated.FilterCondition;
+import org.apache.flink.table.runtime.generated.GeneratedFilterCondition;
+import org.apache.flink.table.runtime.generated.GeneratedFunction;
+import org.apache.flink.table.runtime.keyselector.RowDataKeySelector;
+import org.apache.flink.table.runtime.typeutils.RowDataSerializer;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.util.Preconditions;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This handler represents one of the lookup actions when performing cascaded lookups on multi
+ * dimension tables.
+ *
+ * <p>For example, if the lookup chain is `[D -> A, A -> B, (A, B) -> C]`, there are three {@link
+ * CascadedLookupHandler}, each representing one of the lookup actions within the sequence.
+ */
+public class CascadedLookupHandler extends LookupHandlerBase {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final Logger LOG = LoggerFactory.getLogger(CascadedLookupHandler.class);
+
+    // used for debug and start with 1
+    protected final int id;
+    private @Nullable final GeneratedFilterCondition generatedRemainingCondition;
+    private final RowDataKeySelector streamSideLookupKeySelector;
+    private final boolean leftLookupRight;
+
+    private @Nullable transient FilterCondition remainingCondition;
+    private transient Map<RowData, List<RowData>> allInputsWithLookupKey;
+    private transient Map<RowData, Collection<RowData>> lookupResults;
+
+    protected @Nullable transient Integer totalNumShouldBeHandledThisRound = null;
+    protected @Nullable transient Integer handledNum = null;
+
+    public CascadedLookupHandler(
+            int id,
+            DataType streamSideType,
+            DataType lookupResultType,
+            DataType lookupSidePassThroughCalcType,
+            RowDataSerializer lookupSidePassThroughCalcRowSerializer,
+            @Nullable GeneratedFunction<FlatMapFunction<RowData, RowData>> lookupSideGeneratedCalc,
+            @Nullable GeneratedFilterCondition generatedRemainingCondition,
+            RowDataKeySelector streamSideLookupKeySelector,
+            int[] ownedSourceOrdinals,
+            int ownedLookupOrdinal,
+            boolean leftLookupRight) {
+        super(
+                streamSideType,
+                lookupResultType,
+                lookupSidePassThroughCalcType,
+                lookupSidePassThroughCalcRowSerializer,
+                lookupSideGeneratedCalc,
+                ownedSourceOrdinals,
+                ownedLookupOrdinal,
+                "CascadedLookupHandler-" + id);
+        this.id = id;
+        this.generatedRemainingCondition = generatedRemainingCondition;
+        this.streamSideLookupKeySelector = streamSideLookupKeySelector;
+
+        if (leftLookupRight) {
+            Preconditions.checkArgument(
+                    Arrays.stream(ownedSourceOrdinals).allMatch(i -> i < ownedLookupOrdinal));
+        } else {
+            Preconditions.checkArgument(
+                    Arrays.stream(ownedSourceOrdinals).allMatch(i -> i > ownedLookupOrdinal));
+        }
+        this.leftLookupRight = leftLookupRight;
+    }
+
+    @Override
+    public void setNext(@Nullable DeltaJoinHandlerBase next) {
+        super.setNext(next);
+
+        Preconditions.checkArgument(
+                next != null, "This cascaded lookup handler must have a concrete handler after it");
+    }
+
+    @Override
+    public void open(OpenContext openContext, DeltaJoinHandlerContext handlerContext)
+            throws Exception {
+        super.open(openContext, handlerContext);
+
+        RuntimeContext runtimeContext = handlerContext.getRuntimeContext();
+
+        if (generatedRemainingCondition != null) {
+            this.remainingCondition =
+                    generatedRemainingCondition.newInstance(
+                            runtimeContext.getUserCodeClassLoader());
+            FunctionUtils.setFunctionRuntimeContext(remainingCondition, runtimeContext);
+            FunctionUtils.openFunction(remainingCondition, openContext);
+        }
+
+        this.lookupResults = new HashMap<>();
+        this.allInputsWithLookupKey = new HashMap<>();
+
+        Preconditions.checkState(
+                next != null, "This cascaded lookup handler must have a concrete handler after it");
+    }
+
+    @Override
+    public void asyncHandle() throws Exception {
+        Preconditions.checkState(
+                totalNumShouldBeHandledThisRound == null && handledNum == null,
+                "This handler is handled without being reset");
+
+        Collection<RowData> allSourceRowData =
+                handlerContext.getSharedMultiInputRowDataBuffer().getData(ownedSourceOrdinals);
+
+        for (RowData input : allSourceRowData) {
+            RowData lookupKey = streamSideLookupKeySelector.getKey(input);
+            allInputsWithLookupKey.compute(
+                    lookupKey,
+                    (k, v) -> {
+                        if (v == null) {
+                            v = new ArrayList<>();
+                        }
+                        v.add(input);
+                        return v;
+                    });
+        }
+
+        totalNumShouldBeHandledThisRound = allInputsWithLookupKey.size();
+        handledNum = 0;
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(
+                    "Begin to lookup from {} to {}, total round: {}, current round: {}",
+                    Arrays.toString(ownedSourceOrdinals),
+                    ownedLookupOrdinal,
+                    totalNumShouldBeHandledThisRound,
+                    handledNum);
+        }
+
+        if (allSourceRowData.isEmpty()) {
+            finish();
+            return;
+        }
+
+        for (List<RowData> inputsOnThisLookupKey : allInputsWithLookupKey.values()) {
+            // pick the first row as input to lookup
+            RowData chosenToLookupInput = inputsOnThisLookupKey.get(0);
+            fetcher.asyncInvoke(chosenToLookupInput, createLookupResultFuture(chosenToLookupInput));
+        }
+    }
+
+    @Override
+    protected void completeResultsInMailbox(RowData input, Collection<RowData> result) {
+        Preconditions.checkState(
+                totalNumShouldBeHandledThisRound != null && handledNum != null,
+                "This handler is completed without being handled");
+
+        lookupResults.put(input, result);
+
+        handledNum++;
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(
+                    "End to lookup from {} to {}, total round: {}, next round: {}",
+                    Arrays.toString(ownedSourceOrdinals),
+                    ownedLookupOrdinal,
+                    totalNumShouldBeHandledThisRound,
+                    handledNum);
+        }
+
+        if (noFurtherInput()) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug(
+                        "There is no further input when looking up from {} to {}, total round: {}, next round: {}",
+                        Arrays.toString(ownedSourceOrdinals),
+                        ownedLookupOrdinal,
+                        totalNumShouldBeHandledThisRound,
+                        handledNum);
+            }
+            try {
+                finish();
+            } catch (Exception t) {
+                LOG.error("Error happened in the lookup chain when finishing", t);
+                completeExceptionally(t);
+            }
+        }
+    }
+
+    private boolean noFurtherInput() {
+        Preconditions.checkState(

Review Comment:
   nit: sort of duplicated validation in `completeResultsInMailbox`



##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/join/deltajoin/CascadedLookupHandler.java:
##########
@@ -0,0 +1,322 @@
+/*
+ * 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.runtime.operators.join.deltajoin;
+
+import org.apache.flink.api.common.functions.FlatMapFunction;
+import org.apache.flink.api.common.functions.OpenContext;
+import org.apache.flink.api.common.functions.RuntimeContext;
+import org.apache.flink.api.common.functions.util.FunctionUtils;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.utils.JoinedRowData;
+import org.apache.flink.table.runtime.generated.FilterCondition;
+import org.apache.flink.table.runtime.generated.GeneratedFilterCondition;
+import org.apache.flink.table.runtime.generated.GeneratedFunction;
+import org.apache.flink.table.runtime.keyselector.RowDataKeySelector;
+import org.apache.flink.table.runtime.typeutils.RowDataSerializer;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.util.Preconditions;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This handler represents one of the lookup actions when performing cascaded lookups on multi
+ * dimension tables.
+ *
+ * <p>For example, if the lookup chain is `[D -> A, A -> B, (A, B) -> C]`, there are three {@link
+ * CascadedLookupHandler}, each representing one of the lookup actions within the sequence.
+ */
+public class CascadedLookupHandler extends LookupHandlerBase {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final Logger LOG = LoggerFactory.getLogger(CascadedLookupHandler.class);
+
+    // used for debug and start with 1
+    protected final int id;

Review Comment:
   nit: can be private



##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/join/deltajoin/CascadedLookupHandler.java:
##########
@@ -0,0 +1,322 @@
+/*
+ * 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.runtime.operators.join.deltajoin;
+
+import org.apache.flink.api.common.functions.FlatMapFunction;
+import org.apache.flink.api.common.functions.OpenContext;
+import org.apache.flink.api.common.functions.RuntimeContext;
+import org.apache.flink.api.common.functions.util.FunctionUtils;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.utils.JoinedRowData;
+import org.apache.flink.table.runtime.generated.FilterCondition;
+import org.apache.flink.table.runtime.generated.GeneratedFilterCondition;
+import org.apache.flink.table.runtime.generated.GeneratedFunction;
+import org.apache.flink.table.runtime.keyselector.RowDataKeySelector;
+import org.apache.flink.table.runtime.typeutils.RowDataSerializer;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.util.Preconditions;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This handler represents one of the lookup actions when performing cascaded lookups on multi
+ * dimension tables.
+ *
+ * <p>For example, if the lookup chain is `[D -> A, A -> B, (A, B) -> C]`, there are three {@link
+ * CascadedLookupHandler}, each representing one of the lookup actions within the sequence.
+ */
+public class CascadedLookupHandler extends LookupHandlerBase {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final Logger LOG = LoggerFactory.getLogger(CascadedLookupHandler.class);
+
+    // used for debug and start with 1
+    protected final int id;
+    private @Nullable final GeneratedFilterCondition generatedRemainingCondition;
+    private final RowDataKeySelector streamSideLookupKeySelector;
+    private final boolean leftLookupRight;
+
+    private @Nullable transient FilterCondition remainingCondition;
+    private transient Map<RowData, List<RowData>> allInputsWithLookupKey;
+    private transient Map<RowData, Collection<RowData>> lookupResults;
+
+    protected @Nullable transient Integer totalNumShouldBeHandledThisRound = null;
+    protected @Nullable transient Integer handledNum = null;

Review Comment:
   ditto



##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/stream/StreamExecDeltaJoin.java:
##########
@@ -584,8 +592,61 @@ private static LookupHandlerBase generateLookupHandler(
                     node.lookupTableBinaryInputOrdinal);
         }
 
-        // TODO FLINK-39233 Support cascaded delta join in runtime
-        throw new IllegalStateException("Support later");
+        final RowType lookupResultPassThroughCalcRowType;
+        if (node.isLeftLookupRight()) {
+            lookupResultPassThroughCalcRowType =
+                    combineOutputRowType(
+                            sourceStreamType,
+                            lookupSidePassThroughCalcRowType,
+                            node.joinType,
+                            typeFactory);
+        } else {
+            lookupResultPassThroughCalcRowType =
+                    combineOutputRowType(
+                            lookupSidePassThroughCalcRowType,
+                            sourceStreamType,
+                            swapJoinType(node.joinType),
+                            typeFactory);
+        }
+
+        GeneratedFilterCondition generatedRemainingCondition =
+                node.deltaJoinSpec
+                        .getRemainingCondition()
+                        .map(
+                                remainCond ->
+                                        FilterCodeGenerator.generateFilterCondition(
+                                                config,
+                                                planner.getFlinkContext().getClassLoader(),
+                                                remainCond,
+                                                lookupResultPassThroughCalcRowType,
+                                                GENERATED_JOIN_CONDITION_CLASS_NAME))
+                        .orElse(null);
+
+        final RowDataKeySelector streamSideLookupKeySelector =
+                KeySelectorUtil.getRowDataSelector(
+                        classLoader,
+                        lookupKeysOnInputSide.stream()
+                                .mapToInt(
+                                        key -> {
+                                            Preconditions.checkState(
+                                                    key instanceof FunctionCallUtil.FieldRef);

Review Comment:
   Add proper error msg.



-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39233][table-runtime] Support cascaded delta join runtime [flink]

Posted by "xuyangzhong (via GitHub)" <gi...@apache.org>.
xuyangzhong commented on code in PR #27828:
URL: https://github.com/apache/flink/pull/27828#discussion_r2992763130


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/join/deltajoin/CascadedLookupHandler.java:
##########
@@ -0,0 +1,322 @@
+/*
+ * 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.runtime.operators.join.deltajoin;
+
+import org.apache.flink.api.common.functions.FlatMapFunction;
+import org.apache.flink.api.common.functions.OpenContext;
+import org.apache.flink.api.common.functions.RuntimeContext;
+import org.apache.flink.api.common.functions.util.FunctionUtils;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.utils.JoinedRowData;
+import org.apache.flink.table.runtime.generated.FilterCondition;
+import org.apache.flink.table.runtime.generated.GeneratedFilterCondition;
+import org.apache.flink.table.runtime.generated.GeneratedFunction;
+import org.apache.flink.table.runtime.keyselector.RowDataKeySelector;
+import org.apache.flink.table.runtime.typeutils.RowDataSerializer;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.util.Preconditions;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This handler represents one of the lookup actions when performing cascaded lookups on multi
+ * dimension tables.
+ *
+ * <p>For example, if the lookup chain is `[D -> A, A -> B, (A, B) -> C]`, there are three {@link
+ * CascadedLookupHandler}, each representing one of the lookup actions within the sequence.
+ */
+public class CascadedLookupHandler extends LookupHandlerBase {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final Logger LOG = LoggerFactory.getLogger(CascadedLookupHandler.class);
+
+    // used for debug and start with 1
+    protected final int id;
+    private @Nullable final GeneratedFilterCondition generatedRemainingCondition;
+    private final RowDataKeySelector streamSideLookupKeySelector;
+    private final boolean leftLookupRight;
+
+    private @Nullable transient FilterCondition remainingCondition;
+    private transient Map<RowData, List<RowData>> allInputsWithLookupKey;
+    private transient Map<RowData, Collection<RowData>> lookupResults;
+
+    protected @Nullable transient Integer totalNumShouldBeHandledThisRound = null;
+    protected @Nullable transient Integer handledNum = null;
+
+    public CascadedLookupHandler(
+            int id,
+            DataType streamSideType,
+            DataType lookupResultType,
+            DataType lookupSidePassThroughCalcType,
+            RowDataSerializer lookupSidePassThroughCalcRowSerializer,
+            @Nullable GeneratedFunction<FlatMapFunction<RowData, RowData>> lookupSideGeneratedCalc,
+            @Nullable GeneratedFilterCondition generatedRemainingCondition,
+            RowDataKeySelector streamSideLookupKeySelector,
+            int[] ownedSourceOrdinals,
+            int ownedLookupOrdinal,
+            boolean leftLookupRight) {
+        super(
+                streamSideType,
+                lookupResultType,
+                lookupSidePassThroughCalcType,
+                lookupSidePassThroughCalcRowSerializer,
+                lookupSideGeneratedCalc,
+                ownedSourceOrdinals,
+                ownedLookupOrdinal,
+                "CascadedLookupHandler-" + id);
+        this.id = id;
+        this.generatedRemainingCondition = generatedRemainingCondition;
+        this.streamSideLookupKeySelector = streamSideLookupKeySelector;
+
+        if (leftLookupRight) {
+            Preconditions.checkArgument(
+                    Arrays.stream(ownedSourceOrdinals).allMatch(i -> i < ownedLookupOrdinal));
+        } else {
+            Preconditions.checkArgument(
+                    Arrays.stream(ownedSourceOrdinals).allMatch(i -> i > ownedLookupOrdinal));
+        }
+        this.leftLookupRight = leftLookupRight;
+    }
+
+    @Override
+    public void setNext(@Nullable DeltaJoinHandlerBase next) {
+        super.setNext(next);
+
+        Preconditions.checkArgument(
+                next != null, "This cascaded lookup handler must have a concrete handler after it");
+    }
+
+    @Override
+    public void open(OpenContext openContext, DeltaJoinHandlerContext handlerContext)
+            throws Exception {
+        super.open(openContext, handlerContext);
+
+        RuntimeContext runtimeContext = handlerContext.getRuntimeContext();
+
+        if (generatedRemainingCondition != null) {
+            this.remainingCondition =
+                    generatedRemainingCondition.newInstance(
+                            runtimeContext.getUserCodeClassLoader());
+            FunctionUtils.setFunctionRuntimeContext(remainingCondition, runtimeContext);
+            FunctionUtils.openFunction(remainingCondition, openContext);
+        }
+
+        this.lookupResults = new HashMap<>();
+        this.allInputsWithLookupKey = new HashMap<>();
+
+        Preconditions.checkState(
+                next != null, "This cascaded lookup handler must have a concrete handler after it");
+    }
+
+    @Override
+    public void asyncHandle() throws Exception {
+        Preconditions.checkState(
+                totalNumShouldBeHandledThisRound == null && handledNum == null,
+                "This handler is handled without being reset");
+
+        Collection<RowData> allSourceRowData =
+                handlerContext.getSharedMultiInputRowDataBuffer().getData(ownedSourceOrdinals);
+
+        for (RowData input : allSourceRowData) {
+            RowData lookupKey = streamSideLookupKeySelector.getKey(input);
+            allInputsWithLookupKey.compute(
+                    lookupKey,
+                    (k, v) -> {
+                        if (v == null) {
+                            v = new ArrayList<>();
+                        }
+                        v.add(input);
+                        return v;
+                    });
+        }
+
+        totalNumShouldBeHandledThisRound = allInputsWithLookupKey.size();
+        handledNum = 0;
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(
+                    "Begin to lookup from {} to {}, total round: {}, current round: {}",
+                    Arrays.toString(ownedSourceOrdinals),
+                    ownedLookupOrdinal,
+                    totalNumShouldBeHandledThisRound,
+                    handledNum);
+        }
+
+        if (allSourceRowData.isEmpty()) {
+            finish();
+            return;
+        }
+
+        for (List<RowData> inputsOnThisLookupKey : allInputsWithLookupKey.values()) {
+            // pick the first row as input to lookup
+            RowData chosenToLookupInput = inputsOnThisLookupKey.get(0);
+            fetcher.asyncInvoke(chosenToLookupInput, createLookupResultFuture(chosenToLookupInput));
+        }
+    }
+
+    @Override
+    protected void completeResultsInMailbox(RowData input, Collection<RowData> result) {
+        Preconditions.checkState(
+                totalNumShouldBeHandledThisRound != null && handledNum != null,
+                "This handler is completed without being handled");
+
+        lookupResults.put(input, result);
+
+        handledNum++;
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(
+                    "End to lookup from {} to {}, total round: {}, next round: {}",
+                    Arrays.toString(ownedSourceOrdinals),
+                    ownedLookupOrdinal,
+                    totalNumShouldBeHandledThisRound,
+                    handledNum);
+        }
+
+        if (noFurtherInput()) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug(
+                        "There is no further input when looking up from {} to {}, total round: {}, next round: {}",
+                        Arrays.toString(ownedSourceOrdinals),
+                        ownedLookupOrdinal,
+                        totalNumShouldBeHandledThisRound,
+                        handledNum);
+            }
+            try {
+                finish();
+            } catch (Exception t) {
+                LOG.error("Error happened in the lookup chain when finishing", t);
+                completeExceptionally(t);
+            }
+        }
+    }
+
+    private boolean noFurtherInput() {
+        Preconditions.checkState(

Review Comment:
   Great catch! Removed



-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-39233][table-runtime] Support cascaded delta join runtime [flink]

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #27828:
URL: https://github.com/apache/flink/pull/27828#issuecomment-4125739603

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "ecdce70a35132027891b2d4dcbb4c192bef1b487",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ecdce70a35132027891b2d4dcbb4c192bef1b487",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * ecdce70a35132027891b2d4dcbb4c192bef1b487 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org