JingsongLi commented on code in PR #1416:
URL: https://github.com/apache/incubator-paimon/pull/1416#discussion_r1236666639
##########
paimon-core/src/main/java/org/apache/paimon/mergetree/compact/PartialUpdateMergeFunction.java:
##########
@@ -190,11 +195,36 @@ private Factory(Options options, RowType rowType) {
@Override
public MergeFunction<KeyValue> create(@Nullable int[][] projection) {
List<DataType> fieldTypes = tableTypes;
+ Map<Integer, SequenceGenerator> projectedFieldSequences = new
HashMap<>();
+
if (projection != null) {
fieldTypes = Projection.of(projection).project(tableTypes);
+ int[] projects = Projection.of(projection).toTopLevelIndexes();
+ Map<Integer, Integer> indexMap = new HashMap<>();
+ for (int i = 0; i < projects.length; i++) {
+ indexMap.put(projects[i], i);
+ }
+ fieldSequences.forEach(
+ (field, sequence) -> {
+ int newField = indexMap.getOrDefault(field, -1);
+ if (newField != -1) {
+ int newSequenceId =
indexMap.getOrDefault(sequence.index(), -1);
+ if (newSequenceId != -1) {
+ projectedFieldSequences.put(
+ newField,
+ new SequenceGenerator(
+ newSequenceId,
sequence.fieldType()));
+ }
+ }
+ });
Review Comment:
`return new PartialUpdateMergeFunction(createFieldGetters(fieldTypes),
ignoreDelete, projectedFieldSequences);`
here.
##########
paimon-core/src/main/java/org/apache/paimon/mergetree/compact/PartialUpdateMergeFunction.java:
##########
@@ -190,11 +195,36 @@ private Factory(Options options, RowType rowType) {
@Override
public MergeFunction<KeyValue> create(@Nullable int[][] projection) {
List<DataType> fieldTypes = tableTypes;
+ Map<Integer, SequenceGenerator> projectedFieldSequences = new
HashMap<>();
+
if (projection != null) {
Review Comment:
```
if (project != null) {
List<DataType> fieldTypes = tableTypes;
Map<Integer, SequenceGenerator> projectedFieldSequences = new
HashMap<>();
.....
return new PartialUpdateMergeFunction(createFieldGetters(fieldTypes),
ignoreDelete, projectedFieldSequences);
} else {
return new PartialUpdateMergeFunction(createFieldGetters(tableTypes),
ignoreDelete, fieldSequences);
}
```
here.
##########
paimon-core/src/test/java/org/apache/paimon/mergetree/compact/PartialUpdateMergeFunctionTest.java:
##########
@@ -113,6 +310,46 @@ private void add(
GenericRow.of(f0, f1, f2, f3, f4, f5, f6)));
}
+ private void add(
+ MergeFunction<KeyValue> function,
+ Integer f0,
Review Comment:
Object... values
##########
paimon-core/src/test/java/org/apache/paimon/mergetree/compact/PartialUpdateMergeFunctionTest.java:
##########
@@ -113,6 +310,46 @@ private void add(
GenericRow.of(f0, f1, f2, f3, f4, f5, f6)));
}
+ private void add(
+ MergeFunction<KeyValue> function,
+ Integer f0,
+ Integer f1,
+ Integer f2,
+ Integer f3,
+ Integer f4,
+ Integer f5,
+ Integer f6,
+ Integer f7) {
+ function.add(
+ new KeyValue()
+ .replace(
+ GenericRow.of(1),
+ sequence++,
+ RowKind.INSERT,
+ GenericRow.of(f0, f1, f2, f3, f4, f5, f6,
f7)));
+ }
+
+ private void validate(
+ MergeFunction<KeyValue> function,
+ Integer f0,
Review Comment:
Object... values
--
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]