You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/04/07 06:02:33 UTC

[GitHub] [iceberg] pvary commented on a change in pull request #2407: Hive: Synchronize equivalent HMS and Iceberg properties

pvary commented on a change in pull request #2407:
URL: https://github.com/apache/iceberg/pull/2407#discussion_r608361767



##########
File path: hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
##########
@@ -86,6 +90,28 @@
       .impl(HiveMetaStoreClient.class, "alter_table",
           String.class, String.class, Table.class, EnvironmentContext.class)
       .build();
+  private static final BiMap<String, String> ICEBERG_TO_HMS_TRANSLATION = ImmutableBiMap.of(
+      // gc.enabled in Iceberg and external.table.purge in Hive are meant to do the same things but with different names
+      GC_ENABLED, "external.table.purge"
+  );
+
+
+  /**
+   * Provides key translation where necessary between Iceberg and HMS props. This translation is needed because some
+   * properties control the same behaviour but are named differently in Iceberg and Hive. Therefore changes to these
+   * property pairs should be synchronized.
+   *
+   * Example: Deleting data files upon DROP TABLE is enabled using gc.enabled=true in Iceberg and
+   * external.table.purge=true in Hive. Hive and Iceberg users are unaware of each other's control flags, therefore
+   * inconsistent behaviour can occur from e.g. a Hive user's point of view if external.table.purge=true is set on the
+   * HMS table but gc.enabled=false is set on the Iceberg table, resulting in no data file deletion.
+   *
+   * @param hmsProp The HMS property that should be translated to Iceberg property
+   * @return Iceberg property equivalent to the hmsProp. If no such translation exists, the original hmsProp is returned
+   */
+  public static String translateToIcebergProp(String hmsProp) {
+    return ICEBERG_TO_HMS_TRANSLATION.inverse().getOrDefault(hmsProp, hmsProp);

Review comment:
       How costly  is the inverse call?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org