alexeykudinkin commented on a change in pull request #4709:
URL: https://github.com/apache/hudi/pull/4709#discussion_r803263753
##########
File path:
hudi-client/hudi-spark-client/src/main/scala/org/apache/hudi/HoodieSparkUtils.scala
##########
@@ -293,4 +293,21 @@ object HoodieSparkUtils extends SparkAdapterSupport {
s"${tableSchema.fieldNames.mkString(",")}")
AttributeReference(columnName, field.get.dataType, field.get.nullable)()
}
+
+ def getRequiredSchema(tableAvroSchema: Schema, requiredColumns:
Array[String]): (Schema, StructType) = {
+ // First get the required avro-schema, then convert the avro-schema to
spark schema.
+ val name2Fields = tableAvroSchema.getFields.asScala.map(f => f.name() ->
f).toMap
+ val requiredFields = requiredColumns.map(c => name2Fields(c))
+ .map(f => new Schema.Field(f.name(), f.schema(), f.doc(),
f.defaultVal(), f.order())).toList
Review comment:
Got it. Can you please add a comment elaborating that, so that it's very
clear why it's this way
--
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]