rahil-c commented on code in PR #14374:
URL: https://github.com/apache/hudi/pull/14374#discussion_r2579120074
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala:
##########
@@ -365,16 +365,25 @@ class HoodieSparkSqlWriterInternal {
// NOTE: We need to make sure that upon conversion of the schemas b/w
Catalyst's [[StructType]] and
// Avro's [[Schema]] we're preserving corresponding "record-name"
and "record-namespace" that
// play crucial role in establishing compatibility b/w schemas
- val (avroRecordName, avroRecordNamespace) = latestTableSchemaOpt.map(s
=> (s.getName, s.getNamespace))
+ val (avroRecordName, avroRecordNamespace) = latestTableSchemaOpt.map(s =>
+ (s.getName, toScalaOption(s.getNamespace).orNull))
.getOrElse(getAvroRecordNameAndNamespace(tblName))
- val sourceSchema = convertStructTypeToAvroSchema(df.schema,
avroRecordName, avroRecordNamespace)
+ val sourceSchema = HoodieSchema.fromAvroSchema(
+ convertStructTypeToAvroSchema(df.schema, avroRecordName,
avroRecordNamespace)
+ )
val internalSchemaOpt =
HoodieSchemaUtils.getLatestTableInternalSchema(hoodieConfig,
tableMetaClient).orElse {
// In case we need to reconcile the schema and schema evolution is
enabled,
// we will force-apply schema evolution to the writer's schema
if (shouldReconcileSchema &&
hoodieConfig.getBooleanOrDefault(DataSourceReadOptions.SCHEMA_EVOLUTION_ENABLED))
{
val allowOperationMetaDataField =
parameters.getOrElse(HoodieWriteConfig.ALLOW_OPERATION_METADATA_FIELD.key(),
"false").toBoolean
-
Some(InternalSchemaConverter.convert(HoodieSchema.fromAvroSchema(HoodieAvroUtils.addMetadataFields(latestTableSchemaOpt.getOrElse(sourceSchema),
allowOperationMetaDataField))))
+ //TODO need to rename the spark schema class to something else to
not have this be so confusing
Review Comment:
Yes we currently have this schema utils class in the spark module
https://github.com/apache/hudi/blob/master/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSchemaUtils.scala#L49,
but we also recently have added
`org.apache.hudi.common.schema.HoodieSchemaUtils` so i was wondering if we
should just rename the former to make things less confusing.
--
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]