This is an automated email from the ASF dual-hosted git repository.

snuyanzin pushed a commit to branch release-1.20
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.20 by this push:
     new 042956cb626 [FLINK-38750][table] Validation of queries with functions 
erroneously invoked under `SELECT` fails with `StackOverflow`
042956cb626 is described below

commit 042956cb626513cca1ba074dc3e2707ee2d9b8e7
Author: Gyula Komlossi <[email protected]>
AuthorDate: Tue Dec 2 14:14:22 2025 +0100

    [FLINK-38750][table] Validation of queries with functions erroneously 
invoked under `SELECT` fails with `StackOverflow`
    
    Co-authored-by: Sergey Nuyanzin <[email protected]>
---
 .../inference/TypeInferenceOperandInference.java          |  4 +++-
 .../flink/table/planner/plan/stream/sql/CalcTest.scala    | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git 
a/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/inference/TypeInferenceOperandInference.java
 
b/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/inference/TypeInferenceOperandInference.java
index b59ad75f8d4..700ae364107 100644
--- 
a/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/inference/TypeInferenceOperandInference.java
+++ 
b/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/inference/TypeInferenceOperandInference.java
@@ -74,8 +74,10 @@ public final class TypeInferenceOperandInference implements 
SqlOperandTypeInfere
                     false)) {
                 inferOperandTypesOrError(unwrapTypeFactory(callBinding), 
callContext, operandTypes);
             }
-        } catch (ValidationException | CalciteContextException e) {
+        } catch (ValidationException e) {
             // let operand checker fail
+        } catch (CalciteContextException e) {
+            throw e;
         } catch (Throwable t) {
             throw createUnexpectedException(callContext, t);
         }
diff --git 
a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/CalcTest.scala
 
b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/CalcTest.scala
index 1c62fc054e2..87d3d02d234 100644
--- 
a/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/CalcTest.scala
+++ 
b/flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/CalcTest.scala
@@ -110,6 +110,21 @@ class CalcTest extends TableTestBase {
       .isThrownBy(() => util.tableEnv.sqlQuery("SELECT a, foo FROM MyTable"))
   }
 
+  @Test
+  def testCoalesceOnInvalidField(): Unit = {
+    assertThatExceptionOfType(classOf[ValidationException])
+      .isThrownBy(() => util.verifyExecPlan("SELECT coalesce(SELECT invalid)"))
+      .withMessageContaining("Column 'invalid' not found in any table")
+  }
+
+  @Test
+  def testNestedCoalesceOnInvalidField(): Unit = {
+    assertThatExceptionOfType(classOf[ValidationException])
+      .isThrownBy(
+        () => util.verifyExecPlan("SELECT coalesce(SELECT coalesce(SELECT 
coalesce(invalid)))"))
+      .withMessageContaining("Column 'invalid' not found in any table")
+  }
+
   @Test
   def testPrimitiveMapType(): Unit = {
     util.verifyExecPlan("SELECT MAP[b, 30, 10, a] FROM MyTable")

Reply via email to