alexeykudinkin commented on code in PR #8026:
URL: https://github.com/apache/hudi/pull/8026#discussion_r1117800390
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieBaseRelation.scala:
##########
@@ -155,12 +158,13 @@ abstract class HoodieBaseRelation(val sqlContext:
SQLContext,
}
}
+ val avroNameAndSpace =
AvroConversionUtils.getAvroRecordNameAndNamespace(tableName)
Review Comment:
nit: we can move this inside the map and also make it `val (name, namespace)
= getAvroRecordNameAndNamespace(...)`
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieBaseRelation.scala:
##########
@@ -99,6 +100,8 @@ abstract class HoodieBaseRelation(val sqlContext: SQLContext,
protected val sparkSession: SparkSession = sqlContext.sparkSession
+ protected lazy val tableName = metaClient.getTableConfig.getTableName
Review Comment:
nit: better make this a method so that we don't carry this field additional
when serializing
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieBaseRelation.scala:
##########
@@ -613,8 +617,11 @@ object HoodieBaseRelation extends SparkAdapterSupport {
def apply(file: PartitionedFile): Iterator[InternalRow] = read.apply(file)
}
- def convertToAvroSchema(structSchema: StructType): Schema =
- sparkAdapter.getAvroSchemaConverters.toAvroType(structSchema, nullable =
false, "Record")
+ def convertToAvroSchema(structSchema: StructType, tableName: String ):
Schema = {
+ val (recordName, namespace) =
AvroConversionUtils.getAvroRecordNameAndNamespace(tableName)
+ val avroSchema =
sparkAdapter.getAvroSchemaConverters.toAvroType(structSchema, nullable = false,
recordName, namespace)
+ getAvroSchemaWithDefaults(avroSchema, structSchema)
+ }
Review Comment:
@xiarixiaoyao i still don't understand why we need to set defaults in the
schema. Can you please elaborate on that one?
--
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]