flyrain commented on code in PR #7326:
URL: https://github.com/apache/iceberg/pull/7326#discussion_r1238920919


##########
spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/procedures/CreateChangelogViewProcedure.java:
##########
@@ -228,22 +247,41 @@ private Dataset<Row> applyChangelogIterator(Dataset<Row> 
df, Column[] repartitio
             RowEncoder.apply(schema));
   }
 
-  private Dataset<Row> applyCarryoverRemoveIterator(Dataset<Row> df, Column[] 
repartitionSpec) {
-    Column[] sortSpec = sortSpec(df, repartitionSpec);
+  private Dataset<Row> applyCarryoverRemoveIterator(
+      Dataset<Row> df, Column[] repartitionSpec, boolean netChanges) {
+    Column[] sortSpec = sortSpec(df, repartitionSpec, netChanges);
     StructType schema = df.schema();
 
     return df.repartition(repartitionSpec)
         .sortWithinPartitions(sortSpec)
         .mapPartitions(
             (MapPartitionsFunction<Row, Row>)
-                rowIterator -> ChangelogIterator.removeCarryovers(rowIterator, 
schema),
+                rowIterator ->
+                    netChanges
+                        ? ChangelogIterator.removeNetCarryovers(rowIterator, 
schema)
+                        : ChangelogIterator.removeCarryovers(rowIterator, 
schema),
             RowEncoder.apply(schema));
   }
 
-  private static Column[] sortSpec(Dataset<Row> df, Column[] repartitionSpec) {
-    Column[] sortSpec = new Column[repartitionSpec.length + 1];
-    System.arraycopy(repartitionSpec, 0, sortSpec, 0, repartitionSpec.length);
+  private static Column[] sortSpec(Dataset<Row> df, Column[] repartitionSpec, 
boolean netChanges) {
+    Column[] sortSpec;
+
+    if (netChanges) {
+      Column changeOrdinal = df.col(MetadataColumns.CHANGE_ORDINAL.name());
+      Preconditions.checkState(

Review Comment:
   Removed it anyway.



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