This is an automated email from the ASF dual-hosted git repository.
snuyanzin pushed a commit to branch release-2.2
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-2.2 by this push:
new ad477178625 [FLINK-38750][table] Validation of queries with functions
erroneously invoked under `SELECT` fails with `StackOverflow`
ad477178625 is described below
commit ad47717862567f76216e68a07b474a593382001e
Author: Sergey Nuyanzin <[email protected]>
AuthorDate: Tue Dec 2 14:16:03 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 45ef3e380ee..d6c47d48459 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")