francis0407 commented on a change in pull request #23783: [SPARK-26854][SQL]
Support ANY/SOME subquery
URL: https://github.com/apache/spark/pull/23783#discussion_r258768032
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##########
@@ -1055,6 +1055,26 @@ class AstBuilder(conf: SQLConf) extends
SqlBaseBaseVisitor[AnyRef] with Logging
Exists(plan(ctx.query))
}
+ private def getPredicate(
+ operator: ComparisonOperatorContext): (Expression, Expression) =>
Expression = {
+ operator.getChild(0).asInstanceOf[TerminalNode].getSymbol.getType match {
+ case SqlBaseParser.EQ =>
+ (left, right) => EqualTo(left, right)
Review comment:
When I tried to add unit tests by using `assertEqual(sqlCommand,
expression)` like
```scala
assertEqual(
"a = any (select b from c)",
AnySubquery(Seq('a), ListQuery(table("c").select('b)), EqualTo))
```
It failed because the '=' operator is parsed to a lambda expression defined
in AstBuilder, which is not equal to the function `EqualTo`.
Although I can use
`compareExpressions(defaultParser.parseExpression(...),...)` to test it, I
think change `(left, right) => xxx(left, right)` to `xxx` here would be better.
What do you think? @maropu
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]