uros-db commented on code in PR #46421: URL: https://github.com/apache/spark/pull/46421#discussion_r1592006063
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala: ########## @@ -3943,6 +3943,16 @@ object EliminateUnions extends Rule[LogicalPlan] { } } +/** + * Removes [[Collate]] expressions if the input is already the correct type. + */ +object EliminateCollates extends Rule[LogicalPlan] { + def apply(plan: LogicalPlan): LogicalPlan = plan.transformAllExpressions { + case Collate(child, collation) if child.dataType.sameType(StringType(collation)) => Review Comment: Could we consider something like modifying flags in order to preserve priority? i.e. remove the collate expression like in this rule, but also flag the corresponding StringType as "explicit" in priority - that way we could maintain the desired priority, and also get rid of the extra COLLATE expression -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org