uros-db commented on code in PR #46597:
URL: https://github.com/apache/spark/pull/46597#discussion_r1608240127


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Mode.scala:
##########
@@ -48,6 +49,33 @@ case class Mode(
 
   override def inputTypes: Seq[AbstractDataType] = Seq(AnyDataType)
 
+  override def checkInputDataTypes(): TypeCheckResult = {
+    checkDataType(child.dataType)
+  }
+
+  private def checkDataType(dataType: DataType, level1: Boolean = true): 
TypeCheckResult = {
+    dataType match {
+      case ArrayType(elementType, _) =>
+        checkDataType(elementType, level1 = false)
+      case StructType(fields) =>
+        combineTypeCheckResults(fields.map { field =>
+          checkDataType(field.dataType, level1 = false)
+        })
+      case dt: StringType if !level1 &&
+        !CollationFactory.fetchCollation(dt.collationId).supportsBinaryEquality
+      => TypeCheckResult.TypeCheckFailure(
+        s"Input to function $prettyName was a complex type" +
+          s" with strings collated on non-binary collations," +
+          s" which is not yet supported.")
+      case _ => TypeCheckResult.TypeCheckSuccess
+    }
+  }

Review Comment:
   instead of this recursive check, consider using already existing recursive 
constructs (such as `existsRecursively` in `DataType`)
   
   (see comments above)



-- 
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

Reply via email to