cloud-fan commented on code in PR #46722:
URL: https://github.com/apache/spark/pull/46722#discussion_r1619442328
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/RewriteCollationJoin.scala:
##########
@@ -17,29 +17,68 @@
package org.apache.spark.sql.catalyst.analysis
-import org.apache.spark.sql.catalyst.expressions.{AttributeReference,
CollationKey, Equality}
+import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.plans.logical.{Join, LogicalPlan}
import org.apache.spark.sql.catalyst.rules.Rule
import org.apache.spark.sql.catalyst.util.CollationFactory
+import org.apache.spark.sql.types._
import org.apache.spark.sql.types.StringType
+import org.apache.spark.util.ArrayImplicits.SparkArrayOps
object RewriteCollationJoin extends Rule[LogicalPlan] {
def apply(plan: LogicalPlan): LogicalPlan = plan transform {
case j @ Join(_, _, _, Some(condition), _) =>
val newCondition = condition transform {
case e @ Equality(l: AttributeReference, r: AttributeReference) =>
- (l.dataType, r.dataType) match {
- case (st: StringType, _: StringType)
- if
!CollationFactory.fetchCollation(st.collationId).supportsBinaryEquality =>
- e.withNewChildren(Seq(CollationKey(l), CollationKey(r)))
- case _ =>
- e
- }
+ e.withNewChildren(Seq(processExpression(l, l.dataType),
processExpression(r, r.dataType)))
}
if (!newCondition.fastEquals(condition)) {
j.copy(condition = Some(newCondition))
} else {
j
}
}
+
+ private def processExpression(expr: Expression, dt: DataType): Expression = {
+ dt match {
+ case st: StringType
+ if
!CollationFactory.fetchCollation(st.collationId).supportsBinaryEquality =>
+ CollationKey(expr)
+
+ case StructType(fields) =>
+ processStruct(expr, fields)
+
+ case ArrayType(et, containsNull) =>
+ processArray(expr, et, containsNull)
+
Review Comment:
how about map type? I think we support map type join/grouping keys now?
--
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]