cloud-fan commented on a change in pull request #30465:
URL: https://github.com/apache/spark/pull/30465#discussion_r531417281
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##########
@@ -1404,12 +1396,26 @@ class AstBuilder extends SqlBaseBaseVisitor[AnyRef]
with SQLConfHelper with Logg
case SqlBaseParser.LIKE =>
Option(ctx.quantifier).map(_.getType) match {
case Some(SqlBaseParser.ANY) | Some(SqlBaseParser.SOME) =>
- getLikeQuantifierExprs(ctx.expression).reduceLeft(Or)
+ validate(!ctx.expression.isEmpty, "Expected something between '('
and ')'.", ctx)
+ val expressions = expressionList(ctx.expression)
+ if (expressions.size > 200 && expressions.forall(_.foldable) &&
+ expressions.forall(_.dataType == StringType)) {
+ // If there are many pattern expressions, will throw
StackOverflowError.
+ // So we use LikeAny or NotLikeAny instead.
+ val patterns =
expressions.map(_.eval(EmptyRow).asInstanceOf[UTF8String])
+ ctx.NOT match {
+ case null => LikeAny(e, patterns.toSeq)
+ case _ => NotLikeAny(e, patterns.toSeq)
+ }
+ } else {
+ ctx.expression.asScala.map(expression)
+ .map(p => invertIfNotDefined(new Like(e,
p))).toSeq.reduceLeft(Or)
+ }
case Some(SqlBaseParser.ALL) =>
validate(!ctx.expression.isEmpty, "Expected something between '('
and ')'.", ctx)
- val expressions = ctx.expression.asScala.map(expression)
- if (expressions.size >
SQLConf.get.optimizerLikeAllConversionThreshold &&
- expressions.forall(_.foldable) && expressions.forall(_.dataType
== StringType)) {
+ val expressions = expressionList(ctx.expression)
+ if (expressions.size > 200 && expressions.forall(_.foldable) &&
Review comment:
do we need this `expressions.size > 200` condition? Seems fine if we
always go to the LIKE ALL/ANY version?
----------------------------------------------------------------
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]