nsivabalan commented on a change in pull request #2927:
URL: https://github.com/apache/hudi/pull/2927#discussion_r628807510
##########
File path:
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala
##########
@@ -148,12 +148,21 @@ private[hudi] object HoodieSparkSqlWriter {
sparkContext.getConf.registerKryoClasses(
Array(classOf[org.apache.avro.generic.GenericData],
classOf[org.apache.avro.Schema]))
- val schema =
AvroConversionUtils.convertStructTypeToAvroSchema(df.schema, structName,
nameSpace)
+ var schema =
AvroConversionUtils.convertStructTypeToAvroSchema(df.schema, structName,
nameSpace)
sparkContext.getConf.registerAvroSchemas(schema)
log.info(s"Registered avro schema : ${schema.toString(true)}")
+ var (convertGenRecsToLatestTableSchema, latestSchema) =
schemaNeedsConversion(fs, basePath, sparkContext, schema)
// Convert to RDD[HoodieRecord]
- val genericRecords: RDD[GenericRecord] =
HoodieSparkUtils.createRdd(df, schema, structName, nameSpace)
+ var genericRecords: RDD[GenericRecord] =
HoodieSparkUtils.createRdd(df, schema, structName, nameSpace)
+ if(convertGenRecsToLatestTableSchema) { // if incoming batch is of
old schema but table has evolved schema,
Review comment:
thats what I tried first. but HoodieSparkUtils.createRdd(df with rows
serialized with old schema, latest schema (evolved), ...) actually fails during
deserializing row (with evolved schema). And so I had to go the longer route of
Converting RDD[GenRec] -> Dataset<Row> -> RDD[GenRec]. We can sync up f2f on
this to see if we can simplify things. I am all in if it can be simplified.
--
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]