wenlong88 commented on a change in pull request #18215:
URL: https://github.com/apache/flink/pull/18215#discussion_r777793007
##########
File path:
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/calcite/FlinkPlannerImpl.scala
##########
@@ -145,19 +145,26 @@ class FlinkPlannerImpl(
}
sqlNode match {
case richExplain: SqlRichExplain =>
- val validatedStatement = richExplain.getStatement match {
- case insert: RichSqlInsert =>
- val validatedSource = validator.validate(insert.getSource)
- insert.setOperand(2, validatedSource)
- insert
- case others =>
- validator.validate(others)
- }
- richExplain.setOperand(0, validatedStatement)
+ richExplain.setOperand(0, validate(richExplain.getStatement))
richExplain
- // Insert requires validation but no row validation
- case insert: SqlInsert =>
- validator.validateInsert(insert)
+ case statementSet: SqlStatementSet =>
+ statementSet.getInserts.asScala.zipWithIndex.foreach {
+ case (insert, idx) => statementSet.setOperand(idx,
validate(insert))
+ }
+ statementSet
+ case execute: SqlExecute =>
+ execute.setOperand(0, validate(execute.getStatement))
+ execute
+ case insert: RichSqlInsert =>
+ // We don't support UPSERT INTO semantics (see FLINK-24225).
+ if (insert.isUpsert) {
+ throw new ValidationException(
+ "UPSERT INTO statement is not supported. Please use INSERT INTO
instead.")
+ }
+ // only validate source here.
+ // ignore row type which will be verified in table environment.
+ val validatedSource = validator.validate(insert.getSource)
+ insert.setOperand(2, validatedSource)
Review comment:
yes, insert is not validated before, that is why the plan of match
changed too.
I am not quite familiar with Match, but according to the code generator, the
FINAL function is ignored, so there is no really side effect.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]