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

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


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

commit d875af901b4a3a3a8788977e8bbefe3a6f5491e9
Author: Sergey Nuyanzin <[email protected]>
AuthorDate: Tue Dec 2 14:15:26 2025 +0100

    [FLINK-38750][table] Validation of queries with functions erroneously 
invoked under `SELECT` fails with `StackOverflow`
---
 .../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 fba8d45034f..51835f1004c 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
@@ -81,8 +81,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 13b451aea2b..16b5a1c4ab2 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
@@ -108,6 +108,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