cloud-fan commented on code in PR #46280: URL: https://github.com/apache/spark/pull/46280#discussion_r1603393035
########## sql/api/src/main/scala/org/apache/spark/sql/types/DataType.scala: ########## @@ -208,22 +206,35 @@ object DataType { } // NOTE: Map fields must be sorted in alphabetical order to keep consistent with the Python side. - private[sql] def parseDataType(json: JValue): DataType = json match { + private[sql] def parseDataType( + json: JValue, + fieldPath: String = "", + collationsMap: Map[String, String] = Map.empty): DataType = json match { case JString(name) => - nameToType(name) + collationsMap.get(fieldPath) match { + case Some(collation) => + assertValidTypeForCollations(fieldPath, name, collationsMap) + stringTypeWithCollation(collation) + case _ => nameToType(name) + } case JSortedObject( ("containsNull", JBool(n)), ("elementType", t: JValue), ("type", JString("array"))) => - ArrayType(parseDataType(t), n) + assertValidTypeForCollations(fieldPath, "array", collationsMap) + val elementType = parseDataTypeWithCollation(t, fieldPath + ".element", collationsMap) + ArrayType(elementType, n) case JSortedObject( ("keyType", k: JValue), ("type", JString("map")), ("valueContainsNull", JBool(n)), ("valueType", v: JValue)) => - MapType(parseDataType(k), parseDataType(v), n) + assertValidTypeForCollations(fieldPath, "map", collationsMap) Review Comment: shall we do this assert in the StructType branch as well? -- 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