mxm commented on code in PR #18517:
URL: https://github.com/apache/iceberg/pull/18517#discussion_r4311531406
##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/TableMetadataCache.java:
##########
@@ -266,17 +271,37 @@ private CacheItem(
boolean tableExists,
Set<String> branches,
Map<Integer, Schema> tableSchemas,
+ int currentSchemaId,
Map<Integer, PartitionSpec> specs,
int inputSchemaCacheMaximumSize) {
this.createdTimestampMillis = createdTimestampMillis;
this.tableExists = tableExists;
this.branches = branches;
- this.tableSchemas = tableSchemas;
+ this.tableSchemas = orderSchemas(tableSchemas, currentSchemaId);
this.specs = specs;
this.inputSchemas =
new LRUCache<>(inputSchemaCacheMaximumSize,
CacheItem::inputSchemaEvictionListener);
}
+ static Map<Integer, Schema> orderSchemas(
+ Map<Integer, Schema> tableSchemas, int currentSchemaId) {
+ if (tableSchemas == null) {
+ return null;
+ }
+
+ Map<Integer, Schema> ordered = Maps.newLinkedHashMap();
+ Schema current = tableSchemas.get(currentSchemaId);
+ if (current != null) {
+ ordered.put(currentSchemaId, current);
+ }
+
Review Comment:
I guess rollbacks could lead to an old schema becoming the table schema.
--
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]