cloud-fan commented on code in PR #45285:
URL: https://github.com/apache/spark/pull/45285#discussion_r1508931880
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/rules.scala:
##########
@@ -592,3 +593,28 @@ case class QualifyLocationWithWarehouse(catalog:
SessionCatalog) extends Rule[Lo
c.copy(tableDesc = newTable)
}
}
+
+object CollationCheck extends (LogicalPlan => Unit) {
+ def apply(plan: LogicalPlan): Unit = {
+ plan.foreach {
+ case operator: LogicalPlan =>
+ operator transformExpressionsUp {
+ case e@(_: Collation | _: Collate) =>
+ if (!SQLConf.get.collationEnabled) {
+ throw QueryCompilationErrors.collationNotEnabledError()
+ }
+ e
+ case other =>
+ if (other.children.exists(hasCollationExpression)) {
+ if (!SQLConf.get.collationEnabled) {
+ throw QueryCompilationErrors.collationNotEnabledError()
+ }
+ }
+ other
+ }
+ }
+ }
+
+ private def hasCollationExpression(expression: Expression): Boolean =
Review Comment:
I think it should be `isCollationExpression`, as it checks the given
expression itself, not its children.
--
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]