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


##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/procedures/CreateChangelogViewProcedure.java:
##########
@@ -183,21 +185,26 @@ private boolean shouldComputeUpdateImages(ProcedureInput 
input) {
   }
 
   private Dataset<Row> removeCarryoverRows(Dataset<Row> df, boolean 
netChanges) {
-    Predicate<String> columnsToKeep;
-    if (netChanges) {
-      Set<String> metadataColumn =
-          Sets.newHashSet(
-              MetadataColumns.CHANGE_TYPE.name(),
-              MetadataColumns.CHANGE_ORDINAL.name(),
-              MetadataColumns.COMMIT_SNAPSHOT_ID.name());
-
-      columnsToKeep = column -> !metadataColumn.contains(column);
-    } else {
-      columnsToKeep = column -> 
!column.equals(MetadataColumns.CHANGE_TYPE.name());
-    }
+    Set<String> metadataColumn =
+        netChanges
+            ? Sets.newHashSet(
+                MetadataColumns.CHANGE_TYPE.name(),
+                MetadataColumns.CHANGE_ORDINAL.name(),
+                MetadataColumns.COMMIT_SNAPSHOT_ID.name())
+            : Sets.newHashSet(MetadataColumns.CHANGE_TYPE.name());
+
+    Predicate<StructField> columnsToDiscard =
+        field ->
+            metadataColumn.contains(field.name())
+                // avoid sort on incomparable columns
+                || field.dataType() instanceof MapType
+                || field.dataType() instanceof BinaryType;
 
     Column[] repartitionSpec =
-        
Arrays.stream(df.columns()).filter(columnsToKeep).map(df::col).toArray(Column[]::new);
+        Arrays.stream(df.schema().fields())
+            .filter(Predicate.not(columnsToDiscard))

Review Comment:
   Agreed with @karuppayya that if Spark don't complain the repartition spec 
with map columns, we should keep them. We can skip them in `sortSpec`. However, 
that's not enough, we will need to make changes in `ChangeIterator` to make 
sure skipping-sorting-column works. WDYT?



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