wankunde commented on code in PR #38649:
URL: https://github.com/apache/spark/pull/38649#discussion_r1044038097


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala:
##########
@@ -762,10 +762,40 @@ object LikeSimplification extends Rule[LogicalPlan] with 
PredicateHelper {
           val and = buildBalancedPredicate(replacements.map(Not(_)), And)
           if (remainPatterns.nonEmpty) And(and, l.copy(patterns = 
remainPatterns)) else and
         case l: LikeAny =>
-          val or = buildBalancedPredicate(replacements, Or)
+          val equalPatterns = MutableHashset[Any]()

Review Comment:
   Added benchmark result.
   
   benchmark code:
   ```
   object LikeAnyBenchmark extends SqlBasedBenchmark {
     import spark.implicits._
   
     private val numRows = 10000
     private val width = 5
   
     def withTempTable(tableNames: String*)(f: => Unit): Unit = {
       try f finally tableNames.foreach(spark.catalog.dropTempView)
     }
   
     private def saveAsTable(df: DataFrame, dir: File): Unit = {
       val parquetPath = dir.getCanonicalPath + "/parquet"
       df.write.mode("overwrite").parquet(parquetPath)
       spark.read.parquet(parquetPath).createOrReplaceTempView("parquetTable")
     }
   
     override def runBenchmarkSuite(mainArgs: Array[String]): Unit = {
       withTempPath { dir =>
         withTempTable("parquetTable") {
           val selectExpr = (1 to width).map(i => s"CAST(value + 1000000 AS 
STRING) c$i")
           val df = spark.range(0, numRows, 1, 100)
             .map(_ => Random.nextLong).selectExpr(selectExpr: _*)
           saveAsTable(df, dir)
   
           val benchmark =
             new Benchmark("Multi like query", numRows, minNumIters = 3, output 
= output)
   
           benchmark.addCase("Query with LikeAny simplification", numIters = 3) 
{ _ =>
             val likeAnyExpr =
               Random.shuffle(Range(1000, 1300).map(i =>
                 if (i < 1100) s"'$i%'" else if (i < 1200) s"'%$i'" else s"'$i'"
               )).mkString("c1 like any(", ", ", ")")
             spark.sql(s"SELECT * FROM parquetTable WHERE $likeAnyExpr").noop()
           }
           benchmark.run()
         }
       }
     }
   }
   ```



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to