ajantha-bhat commented on code in PR #6461:
URL: https://github.com/apache/iceberg/pull/6461#discussion_r1053287377


##########
spark/v3.3/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestRequiredDistributionAndOrdering.java:
##########
@@ -298,4 +300,33 @@ public void testRangeDistributionWithQuotedColumnNames() 
throws NoSuchTableExcep
         ImmutableList.of(row(7L)),
         sql("SELECT count(*) FROM %s", tableName));
   }
+
+  @Test
+  public void testSortOrderIdInV1Manifests() {
+    testSortOrder("1");
+  }
+
+  @Test
+  public void testSortOrderIdInV2Manifests() {
+    testSortOrder("2");
+  }
+
+  private void testSortOrder(String formatVersion) {
+    sql(
+        "CREATE TABLE %s (c1 INT, c2 STRING, c3 STRING) USING iceberg 
TBLPROPERTIES('format-version' = '%s')",
+        tableName, formatVersion);
+    Table table = validationCatalog.loadTable(tableIdent);
+    Assert.assertEquals("Table should be unsorted", 0, 
table.sortOrder().orderId());
+
+    sql("ALTER TABLE %s WRITE ORDERED BY c2", tableName);
+    table.refresh();
+    Assert.assertEquals("Table sort order id should be 1", 1, 
table.sortOrder().orderId());
+
+    sql("INSERT INTO %s SELECT 43, 'cc', 'dd'", tableName);
+    // check the contents from the manifest files
+    assertEquals(
+        "Sort order in manifest entry should match the table sort order",
+        ImmutableList.of(row(1)),

Review Comment:
   This was always returning 0 as the `manifest file` was never storing 
`sort_order_id` from Spark. 



-- 
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: [email protected]

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