Skip to content

Commit dc1bfba

Browse files
authored
[hotfix]: Build expected results with partitions value, not hard coded value. (#2295)
1 parent bcebe7f commit dc1bfba

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

fluss-lake/fluss-lake-paimon/src/test/java/org/apache/fluss/lake/paimon/flink/FlinkUnionReadPrimaryKeyTableITCase.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,16 @@ void testUnionReadFullType(Boolean isPartitioned) throws Exception {
9999
// check the status of replica after synced
100100
assertReplicaStatus(bucketLogEndOffset);
101101

102+
List<String> partitions = new ArrayList<>();
103+
if (isPartitioned) {
104+
partitions.addAll(waitUntilPartitions(t1).values());
105+
Collections.sort(partitions);
106+
}
107+
102108
// will read paimon snapshot, won't merge log since it's empty
103109
List<String> resultEmptyLog =
104110
toSortedRows(batchTEnv.executeSql("select * from " + tableName));
105-
String expetedResultFromPaimon = buildExpectedResult(isPartitioned, 0, 1);
111+
String expetedResultFromPaimon = buildExpectedResult(isPartitioned, partitions, 0, 1);
106112
assertThat(resultEmptyLog.toString().replace("+U", "+I"))
107113
.isEqualTo(expetedResultFromPaimon);
108114

@@ -379,7 +385,7 @@ void testUnionReadFullType(Boolean isPartitioned) throws Exception {
379385

380386
// now, query the result, it must be the union result of lake snapshot and log
381387
List<String> result = toSortedRows(batchTEnv.executeSql("select * from " + tableName));
382-
String expectedResult = buildExpectedResult(isPartitioned, 0, 2);
388+
String expectedResult = buildExpectedResult(isPartitioned, partitions, 0, 2);
383389
assertThat(result.toString().replace("+U", "+I")).isEqualTo(expectedResult);
384390

385391
// query with project push down
@@ -987,7 +993,8 @@ private Map<TableBucket, Long> getBucketLogEndOffset(
987993
return bucketLogEndOffsets;
988994
}
989995

990-
private String buildExpectedResult(boolean isPartitioned, int record1, int record2) {
996+
private String buildExpectedResult(
997+
boolean isPartitioned, List<String> partitions, int record1, int record2) {
991998
List<String> records = new ArrayList<>();
992999
records.add(
9931000
"+I[false, 1, 2, 3, 4, 5.1, 6.0, string, 0.09, 10, "
@@ -1014,10 +1021,10 @@ private String buildExpectedResult(boolean isPartitioned, int record1, int recor
10141021
if (isPartitioned) {
10151022
return String.format(
10161023
"[%s, %s, %s, %s]",
1017-
String.format(records.get(record1), "2025"),
1018-
String.format(records.get(record1), "2026"),
1019-
String.format(records.get(record2), "2025"),
1020-
String.format(records.get(record2), "2026"));
1024+
String.format(records.get(record1), partitions.get(0)),
1025+
String.format(records.get(record1), partitions.get(1)),
1026+
String.format(records.get(record2), partitions.get(0)),
1027+
String.format(records.get(record2), partitions.get(1)));
10211028
} else {
10221029
return String.format(
10231030
"[%s, %s]",

0 commit comments

Comments
 (0)