cloud-fan commented on code in PR #50192:
URL: https://github.com/apache/spark/pull/50192#discussion_r1996432346
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -4082,3 +4084,31 @@ object RemoveTempResolvedColumn extends
Rule[LogicalPlan] {
}
}
}
+
+object ReassignAliasNamesWithCollations extends Rule[LogicalPlan] {
+ override def apply(plan: LogicalPlan): LogicalPlan = {
+ plan.resolveExpressionsWithPruning(_.containsPattern(ALIAS)) {
+ case a: Alias if
+ a.resolved &&
+ a.metadata.contains(AUTO_GENERATED_ALIAS) &&
+ hasNonDefaultCollationInTheSubtree(a.child) =>
+ val newName = toPrettySQL(a.child)
+ if (newName != a.name) {
+ a.withName(newName)
+ } else {
+ a
+ }
+ }
+ }
+
+ private def hasNonDefaultCollationInTheSubtree(rootExpression: Expression) =
{
+ rootExpression.exists {
+ case expression =>
+ val dataType = try { Some(expression.dataType) } catch { case ex:
Throwable => None }
Review Comment:
oh I see. Is there a better way to detect collation?
--
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]