rdblue commented on a change in pull request #1932:
URL: https://github.com/apache/iceberg/pull/1932#discussion_r542942340



##########
File path: 
spark2/src/test/java/org/apache/iceberg/examples/SchemaEvolutionTest.java
##########
@@ -84,29 +98,56 @@ public void before() throws IOException {
 
   @Test
   public void addColumnToSchema() {
-    table.updateSchema().addColumn("publisher", 
Types.StringType.get()).commit();
 
-    Dataset<Row> df2 = spark.read().json(dataLocation + "new-books.json");
+    String fieldName = "publisher";
+    Schema schema = table.schema();
+    Assert.assertNull(schema.findField(fieldName));
+
+    table.updateSchema().addColumn(fieldName, Types.StringType.get()).commit();
+
+    Dataset<Row> df1 = spark.read()
+        .json(dataLocation + "books.json");
+    df1 = df1.withColumn(fieldName, new Column(Literal$.MODULE$.apply(null)))
+        .selectExpr("title", "price", "author", "cast(published as 
timestamp)", "genre", "publisher");
 
+    Dataset<Row> df2 = spark.read().json(dataLocation + "new-books.json")
+        .selectExpr("title", "price", "author", "cast(published as 
timestamp)", "genre", "publisher");
+    List<Row> expected = df1.union(df2)
+        .collectAsList();
+
+    // Append data
     df2.select(df2.col("title"), df2.col("price").cast(DataTypes.IntegerType),
         df2.col("author"), df2.col("published").cast(DataTypes.TimestampType),
         df2.col("genre"), df2.col("publisher")).write()
         .format("iceberg")
         .mode("append")
         .save(tableLocation.toString());
+
+    // Read iceberg table
+    Dataset<Row> iceberg = spark.read()
+        .format("iceberg")
+        .load(tableLocation.toString());
+
+    String error = QueryTest$.MODULE$.checkAnswer(iceberg, expected);

Review comment:
       This shouldn't use Spark test internals. There are assertions in Iceberg 
to check rows.




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

Reply via email to