amogh-jahagirdar commented on code in PR #13555:
URL: https://github.com/apache/iceberg/pull/13555#discussion_r2220566766


##########
spark/v4.0/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestRewriteDataFilesProcedure.java:
##########
@@ -976,10 +978,50 @@ public void testRewriteDataFilesSummary() {
             EnvironmentContext.ENGINE_VERSION, v -> 
assertThat(v).startsWith("4.0"));
   }
 
+  @TestTemplate
+  public void testRewriteDataFilesPreservesLineage() throws 
NoSuchTableException {
+    createTable(ImmutableMap.of(TableProperties.FORMAT_VERSION, "3"));
+    List<ThreeColumnRecord> records = Lists.newArrayList();
+    for (int i = 0; i < 10; i++) {
+      records.add(new ThreeColumnRecord(i, null, null));
+    }
+
+    spark
+        .createDataFrame(records, ThreeColumnRecord.class)
+        .repartition(10)
+        .writeTo(tableName)
+        .append();
+    List<Object[]> expectedRowsWithLineage =
+        sql("SELECT c1, _row_id, _last_updated_sequence_number FROM %s ORDER 
BY c1", tableName);
+    List<Object[]> output =
+        sql("CALL %s.system.rewrite_data_files(table => '%s')", catalogName, 
tableIdent);
+
+    assertEquals(
+        "Action should rewrite 10 data files and add 1 data file",
+        row(10, 1),
+        Arrays.copyOf(output.get(0), 2));
+
+    List<Object[]> rowsWithLineageAfterRewrite =
+        sql("SELECT c1, _row_id, _last_updated_sequence_number FROM %s ORDER 
BY c1", tableName);
+    assertEquals(
+        "Rows with lineage before rewrite should equal rows with lineage after 
rewrite",
+        expectedRowsWithLineage,
+        rowsWithLineageAfterRewrite);
+  }
+
   private void createTable() {
     sql("CREATE TABLE %s (c1 int, c2 string, c3 string) USING iceberg", 
tableName);
   }
 
+  private void createTable(Map<String, String> properties) {

Review Comment:
   Done!



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

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

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