rdblue commented on a change in pull request #1932:
URL: https://github.com/apache/iceberg/pull/1932#discussion_r542943454
##########
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");
Review comment:
I don't think that this additional check is needed. This is an example,
not really a correctness or unit test. So we want the example to be as simple
as possible to be readable as an example of using the API. This only lives in
tests so that it is kept up to date and we know it doesn't fail.
----------------------------------------------------------------
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]