maropu commented on a change in pull request #23783: [SPARK-26854][SQL] Support
ANY/SOME subquery
URL: https://github.com/apache/spark/pull/23783#discussion_r257505176
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
##########
@@ -195,15 +201,112 @@ case class InSubquery(values: Seq[Expression], query:
ListQuery)
TypeUtils.checkForOrderingExpr(value.dataType, s"function $prettyName")
}
}
-
+ // scalastyle:on line.size.limit
override def children: Seq[Expression] = values :+ query
override def nullable: Boolean = children.exists(_.nullable)
override def foldable: Boolean = children.forall(_.foldable)
+}
+
+object PredicateSubquery {
+ /**
+ * Rewrite `NotEqualTo` as `Not(EqualTo)` and reserve others.
+ */
+ def rewritePredicate(cmp: BinaryComparison)
+ : (Expression, Expression) => Expression = cmp match {
+ case _: NotEqualTo =>
+ (left, right) => Not(EqualTo(left, right))
+ case other =>
+ getPredicate(cmp)
+ }
+
+ def getPredicate(cmp: BinaryComparison)
+ : (Expression, Expression) => BinaryComparison = cmp match {
+ case _: EqualTo =>
+ EqualTo
+ case _: EqualNullSafe =>
+ EqualNullSafe
+ case _: NotEqualTo =>
+ NotEqualTo
+ case _: LessThan =>
+ LessThan
+ case _: LessThanOrEqual =>
+ LessThanOrEqual
+ case _: GreaterThan =>
+ GreaterThan
+ case _: GreaterThanOrEqual =>
+ GreaterThanOrEqual
+ }
+
+ private def combineValues(values: Seq[Expression]): Expression = {
Review comment:
How about moving this transformation into `AstBuidler`?
----------------------------------------------------------------
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]