cloud-fan commented on a change in pull request #28875:
URL: https://github.com/apache/spark/pull/28875#discussion_r443951058
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##########
@@ -468,13 +458,25 @@ class AstBuilder(conf: SQLConf) extends
SqlBaseBaseVisitor[AnyRef] with Logging
throw new ParseException("There must be at least one WHEN clause in a
MERGE statement", ctx)
}
// children being empty means that the condition is not set
- if (matchedActions.length == 2 && matchedActions.head.children.isEmpty) {
- throw new ParseException("When there are 2 MATCHED clauses in a MERGE
statement, " +
- "the first MATCHED clause must have a condition", ctx)
- }
- if (matchedActions.groupBy(_.getClass).mapValues(_.size).exists(_._2 > 1))
{
+ val matchedActionSize = matchedActions.length
+ if (matchedActionSize >= 2 &&
!matchedActions.init.forall(_.condition.nonEmpty)) {
+ throw new ParseException(
+ s"When there are $matchedActionSize MATCHED clauses in a MERGE
statement, " +
Review comment:
can we make the error message simpler?
```
When there are more than one MATCHED clauses in a MERGE statement, only
the last MATCHED clause can omit the condition.
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]