RussellSpitzer commented on code in PR #1378:
URL: https://github.com/apache/polaris/pull/1378#discussion_r2049274034
##########
service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java:
##########
@@ -1184,16 +1200,55 @@ public ViewBuilder withLocation(String newLocation) {
}
}
- private class BasePolarisTableOperations extends
BaseMetastoreTableOperations {
+ public class BasePolarisTableOperations extends BaseMetastoreTableOperations
{
private final TableIdentifier tableIdentifier;
private final String fullTableName;
+ private final boolean updateMetadataOnCommit;
private FileIO tableFileIO;
- BasePolarisTableOperations(FileIO defaultFileIO, TableIdentifier
tableIdentifier) {
+ // TODO remove the following if the Iceberg library allows us to do this
without reflection
+ // For more details see:
+ // https://github.com/apache/polaris/pull/1378
+ private static final Unsafe unsafe;
+ private static final Field tableMetadataField;
+ private static final long changesFieldOffset;
+ private static final Field currentMetadataLocationField;
+ private static final Field currentMetadataField;
+
+ static {
+ try {
+ tableMetadataField =
TableMetadata.class.getDeclaredField("metadataFileLocation");
+ tableMetadataField.setAccessible(true);
+
+ Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
+ unsafeField.setAccessible(true);
+ unsafe = (Unsafe) unsafeField.get(null);
+ Field changesField = TableMetadata.class.getDeclaredField("changes");
+ changesField.setAccessible(true);
+ changesFieldOffset = unsafe.objectFieldOffset(changesField);
+
+ currentMetadataLocationField =
+
BaseMetastoreTableOperations.class.getDeclaredField("currentMetadataLocation");
+ currentMetadataLocationField.setAccessible(true);
+
+ currentMetadataField =
+
BaseMetastoreTableOperations.class.getDeclaredField("currentMetadata");
+ currentMetadataField.setAccessible(true);
+ } catch (IllegalAccessException | NoSuchFieldException e) {
+ LOGGER.error(
+ "Encountered an unexpected error while attempting to access
private fields in TableMetadata",
Review Comment:
Minor suggestion here but we should probably tell the user to disable the
Behavior change which would lead them down this path. That said I'm not sure
how they would get to this point unless they were running a custom Polaris
build with a version of Iceberg where these core fields were renamed or removed.
--
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]