chenjunjiedada commented on a change in pull request #830:
URL: https://github.com/apache/incubator-iceberg/pull/830#discussion_r429031390



##########
File path: 
spark/src/test/java/org/apache/iceberg/spark/source/TestSparkTableUtil.java
##########
@@ -199,4 +204,41 @@ public void testImportAsHiveTable() throws Exception {
     long count2 = spark.read().format("iceberg").load(DB_NAME + 
".test_partitioned_table").count();
     Assert.assertEquals("three values ", 3, count2);
   }
+
+  @Test
+  public void testImportWithIncompatibleSchema() throws Exception {
+    spark.table(qualifiedTableName).write().mode("overwrite").format("parquet")
+        .saveAsTable("original_table");
+
+    // The field is different so that it will project with name mapping
+    Schema filteredSchema = new Schema(
+            optional(1, "data", Types.StringType.get())
+    );
+
+    TableIdentifier source = new TableIdentifier("original_table");
+    Table table = catalog.createTable(
+        org.apache.iceberg.catalog.TableIdentifier.of(DB_NAME, "target_table"),
+        filteredSchema,
+        SparkSchemaUtil.specForTable(spark, "original_table"));
+    File stagingDir = temp.newFolder("staging-dir");
+    SparkTableUtil.importSparkTable(spark, source, table, 
stagingDir.toString());

Review comment:
       Parsing name mapping make sense to me, that could be used for avro and 
orc as well.  While this would need to parse the string from table property to 
NameMapping, how about we make this as a follow-up and use a default name 
mapping created from table schema as I describe above? 




----------------------------------------------------------------
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:
us...@infra.apache.org



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

Reply via email to