dramaticlly commented on code in PR #11045: URL: https://github.com/apache/iceberg/pull/11045#discussion_r1739202341
########## 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: I think spark does not seem to complain about have those columns in repartitioned spec, if you have more spark background can you share a bit more what's the best practise and whether we shall remove? -- 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