rdblue commented on a change in pull request #1525:
URL: https://github.com/apache/iceberg/pull/1525#discussion_r535794513
##########
File path: spark/src/main/java/org/apache/iceberg/actions/Actions.java
##########
@@ -77,6 +82,120 @@ public ExpireSnapshotsAction expireSnapshots() {
return new ExpireSnapshotsAction(spark, table);
}
+ /**
+ * Converts the provided table into an Iceberg table in place. The table
will no longer be represented by it's
+ * previous provider in the session catalog and a new metadata directory
will be created at the table's location.
+ *
+ * @param tableName Table to be converted
+ * @return {@link CreateAction} to perform migration
+ */
+ public static CreateAction migrate(String tableName) {
+ try {
+ return DynMethods.builder("migrate")
+ .impl(implClass(), String.class).buildStaticChecked()
+ .invoke(tableName);
+ } catch (NoSuchMethodException ex) {
+ throw new UnsupportedOperationException("Migrate is not implemented for
this version of Spark");
+ }
+ }
+
+ /**
+ * Converts the provided table into an Iceberg table in place. The table
will no longer be accesible by it's
+ * previous implementation
+ *
+ * @param tableName Table to be converted
+ * @param spark Spark session to use for looking up table
+ * @return {@link CreateAction} to perform migration
+ */
+ public static CreateAction migrate(SparkSession spark, String tableName) {
+ try {
+ return DynMethods.builder("migrate")
+ .impl(implClass(), SparkSession.class,
String.class).buildStaticChecked()
+ .invoke(spark, tableName);
+ } catch (NoSuchMethodException ex) {
+ throw new UnsupportedOperationException("Migrate is not implemented for
this version of Spark");
+ }
+ }
+
+ /**
+ * Creates an independent Iceberg table based on a given table. The new
Iceberg table can be altered, appended or
+ * deleted without causing any change to the original. New data and metadata
will be created in the default
+ * location for tables of this name in the destination catalog.
+ *
+ * @param sourceTable Original table which is the basis for the new Iceberg
table
+ * @param destTable New Iceberg table being created
+ * @return {@link CreateAction} to perform snapshot
+ */
+ public static CreateAction snapshot(SparkSession spark, String sourceTable,
String destTable) {
+ try {
+ return DynMethods.builder("snapshot")
+ .impl(implClass(), SparkSession.class, String.class,
String.class).buildStaticChecked()
+ .invoke(spark, sourceTable, destTable);
+ } catch (NoSuchMethodException ex) {
+ throw new UnsupportedOperationException("Snapshot is not implemented for
this version of Spark");
+ }
+ }
+
+ /**
+ * Creates an independent Iceberg table based on a given table. The new
Iceberg table can be altered, appended or
+ * deleted without causing any change to the original. New data and metadata
will be created in the default
+ * location for tables of this name in the destination catalog.
+ *
+ * @param sourceTable Original table which is the basis for the new Iceberg
table
+ * @param destTable New Iceberg table being created
+ * @return {@link CreateAction} to perform snapshot
+ */
+ public static CreateAction snapshot(String sourceTable, String destTable) {
+ try {
+ return DynMethods.builder("snapshot")
+ .impl(implClass(), String.class, String.class).buildStaticChecked()
+ .invoke(sourceTable, destTable);
+ } catch (NoSuchMethodException ex) {
+ throw new UnsupportedOperationException("Snapshot is not implemented for
this version of Spark");
+ }
+ }
+
+ /**
+ * Creates an independent Iceberg table based on a given table. The new
Iceberg table can be altered, appended or
+ * deleted without causing any change to the original. New data and metadata
will be created in the
+ * new location passed to this method.
+ *
+ * @param sourceTable Original table which is the basis for the new Iceberg
table
+ * @param destTable New Iceberg table being created
+ * @param location Location for metadata and new data for the new table
+ * @return {@link CreateAction} to perform snapshot
+ */
+ public static CreateAction snapshot(String sourceTable, String destTable,
String location) {
Review comment:
I would probably remove this. I don't see a need to supply location this
way and it adds complexity with an additional dynamic method 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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]