Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3a925f2

Browse files
committed
[FLINK-38750][table] Validation of queries with functions erroneously invoked under select fails with StackOverflow
1 parentbb2b1db commit3a925f2

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

‎flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/inference/TypeInferenceOperandInference.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
importorg.apache.flink.table.types.logical.LogicalType;
3232

3333
importorg.apache.calcite.rel.type.RelDataType;
34-
importorg.apache.calcite.runtime.CalciteContextException;
3534
importorg.apache.calcite.sql.SqlCallBinding;
3635
importorg.apache.calcite.sql.type.SqlOperandTypeInference;
3736

@@ -81,7 +80,7 @@ public void inferOperandTypes(
8180
false)) {
8281
inferOperandTypesOrError(unwrapTypeFactory(callBinding),callContext,operandTypes);
8382
}
84-
}catch (ValidationException|CalciteContextExceptione) {
83+
}catch (ValidationExceptione) {
8584
// let operand checker fail
8685
}catch (Throwablet) {
8786
throwcreateUnexpectedException(callContext,t);

‎flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/calcite/FlinkPlannerImpl.scala‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import org.apache.calcite.rel.`type`.RelDataType
3636
importorg.apache.calcite.rel.{RelFieldCollation,RelRoot}
3737
importorg.apache.calcite.rel.hint.RelHint
3838
importorg.apache.calcite.rex.{RexInputRef,RexNode}
39+
importorg.apache.calcite.runtime.CalciteContextException
3940
importorg.apache.calcite.sql.{SqlBasicCall,SqlCall,SqlHint,SqlKind,SqlNode,SqlNodeList,SqlOperatorTable,SqlSelect,SqlTableRef}
4041
importorg.apache.calcite.sql.advise.SqlAdvisorValidator
4142
importorg.apache.calcite.sql.util.SqlShuttle
@@ -202,7 +203,13 @@ class FlinkPlannerImpl(
202203
}
203204
}catch {
204205
casee:RuntimeException=>
205-
thrownewValidationException(s"SQL validation failed.${e.getMessage}", e)
206+
valreason=
207+
if (e.getCause!=null&& e.getCause.isInstanceOf[CalciteContextException]) {
208+
e.getCause
209+
}else {
210+
e
211+
}
212+
thrownewValidationException(s"SQL validation failed.${reason.getMessage}", reason)
206213
}
207214
}
208215

‎flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/CalcTest.scala‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,23 @@ class CalcTest extends TableTestBase {
108108
.isThrownBy(()=> util.tableEnv.sqlQuery("SELECT a, foo FROM MyTable"))
109109
}
110110

111+
@Test
112+
deftestCoalesceOnInvalidField():Unit= {
113+
assertThatExceptionOfType(classOf[ValidationException])
114+
.isThrownBy(()=> util.verifyExecPlan("SELECT coalesce(SELECT invalid)"))
115+
.havingRootCause()
116+
.withMessageContaining("Column 'invalid' not found in any table")
117+
}
118+
119+
@Test
120+
deftestNestedCoalesceOnInvalidField():Unit= {
121+
assertThatExceptionOfType(classOf[ValidationException])
122+
.isThrownBy(
123+
()=> util.verifyExecPlan("SELECT coalesce(SELECT coalesce(SELECT coalesce(invalid)))"))
124+
.havingRootCause()
125+
.withMessageContaining("Column 'invalid' not found in any table")
126+
}
127+
111128
@Test
112129
deftestPrimitiveMapType():Unit= {
113130
util.verifyExecPlan("SELECT MAP[b, 30, 10, a] FROM MyTable")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp