You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/07/21 05:20:47 UTC
[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #37197: [SPARK-39784][SQL] Put Literal values on the right side of the data source filter after translating Catalyst Expression to data source filter
dongjoon-hyun commented on code in PR #37197:
URL: https://github.com/apache/spark/pull/37197#discussion_r926261840
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala:
##########
@@ -502,11 +502,31 @@ private[sql] object DataSourceV2Strategy {
private def translateLeafNodeFilterV2(predicate: Expression): Option[Predicate] = {
predicate match {
- case PushablePredicate(expr) => Some(expr)
+ case PushablePredicate(expr) =>
+ if (expr.children().length == 2) {
+ expr.children()(0) match {
+ case LiteralValue(_, _) =>
+ Some(new Predicate(flipComparisonFilterName(expr.name()),
+ Array(expr.children()(1), expr.children()(0))))
+ case _ => Some(expr)
+ }
+ } else {
+ Some(expr)
+ }
case _ => None
}
}
+ private def flipComparisonFilterName(filterName: String): String = {
+ filterName match {
+ case ">" => "<"
+ case "<" => ">"
+ case ">=" => "<="
+ case "<=" => ">="
+ case _ => filterName
Review Comment:
We don't need to flip `=`, do we? @zinking
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org