pvary commented on code in PR #14880:
URL: https://github.com/apache/iceberg/pull/14880#discussion_r2634137647


##########
flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/DynamicRecordInternalSerializer.java:
##########
@@ -274,22 +306,59 @@ public void writeSnapshot(DataOutputView out) throws 
IOException {
     @Override
     public void readSnapshot(int readVersion, DataInputView in, ClassLoader 
userCodeClassLoader)
         throws IOException {
+      this.version = readVersion;
       this.writeSchemaAndSpec = in.readBoolean();
     }
 
     @Override
     public TypeSerializerSchemaCompatibility<DynamicRecordInternal> 
resolveSchemaCompatibility(
         TypeSerializerSnapshot<DynamicRecordInternal> oldSerializerSnapshot) {
-      return TypeSerializerSchemaCompatibility.compatibleAsIs();
+      if (oldSerializerSnapshot.getCurrentVersion() == getCurrentVersion()) {
+        return TypeSerializerSchemaCompatibility.compatibleAsIs();
+      }
+      // Old TypeSerializerSnapshots do not contain the serializer cache, but 
the newest one does.
+      // This will also ensure that we always use the up-to-date cache 
alongside with its catalog
+      // configuration.
+      Preconditions.checkNotNull(serializerCache, "serializerCache should not 
be null");
+      try {
+        DynMethods.builder("initializeSerializerCache")
+            .hiddenImpl(
+                DynamicRecordInternalTypeSerializerSnapshot.class, 
TableSerializerCache.class)
+            .build()
+            .invoke(oldSerializerSnapshot, serializerCache);
+      } catch (Exception e) {
+        throw new RuntimeException(
+            "Failed to initialize serializerCache for reading data with old 
serializer", e);
+      }

Review Comment:
   nit: newline



-- 
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]

Reply via email to