nastra commented on code in PR #14291:
URL: https://github.com/apache/iceberg/pull/14291#discussion_r2428080247
##########
spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/procedures/CreateChangelogViewProcedure.java:
##########
@@ -184,16 +185,9 @@ private Dataset<Row> computeUpdateImages(String[]
identifierColumns, Dataset<Row
identifierColumns.length > 0,
"Cannot compute the update images because identifier columns are not
set");
- Column[] repartitionSpec = new Column[identifierColumns.length + 1];
- for (int i = 0; i < identifierColumns.length; i++) {
- repartitionSpec[i] =
df.col(CreateChangelogViewProcedure.delimitedName(identifierColumns[i]));
- }
-
- repartitionSpec[repartitionSpec.length - 1] =
df.col(MetadataColumns.CHANGE_ORDINAL.name());
-
- String[] identifierFields = Arrays.copyOf(identifierColumns,
identifierColumns.length + 1);
- identifierFields[identifierFields.length - 1] =
MetadataColumns.CHANGE_ORDINAL.name();
-
+ String[] identifierFields =
+ ArrayUtil.add(identifierColumns,
MetadataColumns.CHANGE_ORDINAL.name());
+ Column[] repartitionSpec = getColumnReferences(df, identifierFields);
Review Comment:
I guess we could also just simplify this without having to introduce a
separate method:
```
String[] identifierFields =
ArrayUtil.add(identifierColumns,
MetadataColumns.CHANGE_ORDINAL.name());
Column[] repartitionSpec =
Arrays.stream(identifierFields)
.map(col ->
df.col(CreateChangelogViewProcedure.delimitedName(col)))
.toArray(Column[]::new);
```
--
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]