xkrogen commented on a change in pull request #33308:
URL: https://github.com/apache/spark/pull/33308#discussion_r672589300
##########
File path:
external/avro/src/main/scala/org/apache/spark/sql/avro/AvroUtils.scala
##########
@@ -228,6 +236,38 @@ private[sql] object AvroUtils extends Logging {
.groupBy(_.name.toLowerCase(Locale.ROOT))
.mapValues(_.toSeq) // toSeq needed for scala 2.13
+ private[this] val fieldPairs = catalystSchema
+ .zipWithIndex
+ .map(fieldWithPos => (fieldWithPos, getAvroField(fieldWithPos._1.name,
fieldWithPos._2)))
+
+ /**
+ * Get the fields which have matching equivalents in both Avro and
Catalyst schemas.
+ *
+ * @return A sequence of `(catalystField, catalystPosition, avroField)`
tuples.
+ */
+ def getMatchedFields: Seq[(StructField, Int, Schema.Field)] =
fieldPairs.flatMap {
Review comment:
Great suggestion, thanks!
--
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]