HyukjinKwon commented on a change in pull request #26907: [SPARK-30267][SQL] 
Avro arrays can be of any List
URL: https://github.com/apache/spark/pull/26907#discussion_r362690185
 
 

 ##########
 File path: 
external/avro/src/main/scala/org/apache/spark/sql/avro/AvroDeserializer.scala
 ##########
 @@ -167,14 +167,12 @@ class AvroDeserializer(rootAvroType: Schema, 
rootCatalystType: DataType) {
       case (ARRAY, ArrayType(elementType, containsNull)) =>
         val elementWriter = newWriter(avroType.getElementType, elementType, 
path)
         (updater, ordinal, value) =>
-          val array = value.asInstanceOf[GenericData.Array[Any]]
+          val array = value.asInstanceOf[java.util.Collection[Any]]
           val len = array.size()
           val result = createArrayData(elementType, len)
           val elementUpdater = new ArrayDataUpdater(result)
 
-          var i = 0
-          while (i < len) {
-            val element = array.get(i)
+          for ((element, i) <- array.asScala.zipWithIndex) {
 
 Review comment:
   Why did we change this? `zipWithIndex` is discouraged especially in a 
performance sensitive code path 
(https://github.com/databricks/scala-style-guide#perf-whileloops)

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to