amogh-jahagirdar commented on code in PR #12736:
URL: https://github.com/apache/iceberg/pull/12736#discussion_r2048072021
##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkWriteBuilder.java:
##########
@@ -192,11 +200,23 @@ private static Schema validateOrMergeWriteSchema(
// if the validation passed, update the table schema
update.commit();
} else {
- writeSchema = SparkSchemaUtil.convert(table.schema(), dsSchema,
caseSensitive);
+ Schema schema = table.schema();
+ if (writeIncludesRowLineage) {
+ schema = TypeUtil.join(schema, rowLineageSchema(table));
+ }
+
+ writeSchema = SparkSchemaUtil.convert(schema, dsSchema, caseSensitive);
TypeUtil.validateWriteSchema(
table.schema(), writeSchema, writeConf.checkNullability(),
writeConf.checkOrdering());
}
return writeSchema;
}
+
+ private static Schema rowLineageSchema(Table table) {
+ return new Schema(
+ MetadataColumns.metadataColumn(table,
MetadataColumns.ROW_ID.name()).asOptional(),
+ MetadataColumns.metadataColumn(table,
MetadataColumns.LAST_UPDATED_SEQUENCE_NUMBER.name())
+ .asOptional());
Review Comment:
I'm doing this in a few places, maybe move this to TableUtil
--
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]