rdblue commented on a change in pull request #1525:
URL: https://github.com/apache/iceberg/pull/1525#discussion_r538758721
##########
File path: spark3/src/main/java/org/apache/iceberg/actions/SparkActions.java
##########
@@ -20,10 +20,54 @@
package org.apache.iceberg.actions;
import org.apache.iceberg.Table;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.spark.Spark3Util;
import org.apache.spark.sql.SparkSession;
+import org.apache.spark.sql.catalyst.parser.ParseException;
-class SparkActions extends Actions {
+public class SparkActions extends Actions {
protected SparkActions(SparkSession spark, Table table) {
super(spark, table);
}
+
+ public static CreateAction migrate(String tableName) {
+ return migrate(SparkSession.active(), tableName);
+ }
+
+ public static CreateAction migrate(SparkSession spark, String tableName) {
+ Spark3Util.CatalogAndIdentifier catalogAndIdentifier;
+ try {
+ catalogAndIdentifier = Spark3Util.catalogAndIdentifier(spark, tableName);
+ } catch (ParseException e) {
+ throw new IllegalArgumentException("Cannot parse migrate target", e);
Review comment:
There are quite a few try/catch blocks for this. Maybe add a version
that doesn't throw `ParseException` and pass in a context string to form the
error message. Also, the error message should include the table name that
failed parsing:
```java
public static CatalogAndIdentifier catalogAndIdentifier(String description,
SparkSession spark, String tableName) {
try {
return catalogAndIdentifier(spark, tableName);
} catch (ParseException e) {
throw new IllegalArgumentException("Cannot parse " + description + ": "
+ tableName, e);
}
}
```
----------------------------------------------------------------
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]