sarutak commented on a change in pull request #33915:
URL: https://github.com/apache/spark/pull/33915#discussion_r709969891
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/orc/OrcUtils.scala
##########
@@ -85,10 +85,42 @@ object OrcUtils extends Logging {
}
private def toCatalystSchema(schema: TypeDescription): StructType = {
+ import TypeDescription.Category
+
+ def toCatalystType(orcType: TypeDescription): DataType = {
+ orcType.getCategory match {
+ case Category.STRUCT => toStructType(orcType)
+ case Category.LIST => toArrayType(orcType)
+ case Category.MAP => toMapType(orcType)
+ case _ => CatalystSqlParser.parseDataType(orcType.toString)
+ }
+ }
+
+ def toStructType(orcType: TypeDescription): StructType = {
+ val fieldNames = orcType.getFieldNames.asScala
+ val fieldTypes = orcType.getChildren.asScala
+ fieldNames.zip(fieldTypes).foldLeft(new StructType) {
+ case (resultType, (fieldName, fieldType)) =>
+ val catalystType = toCatalystType(fieldType)
+ resultType.add(StructField(fieldName, catalystType))
+ }
+ }
+
+ def toArrayType(orcType: TypeDescription): ArrayType = {
+ val elementType = orcType.getChildren.asScala.head
Review comment:
Exactly. I have no idea why I didn't notice that...
--
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]