Skip to content

Commit 2d0c104

Browse files
committed
add case
1 parent 4cd50af commit 2d0c104

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/DeletionVectorITCase.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
import org.apache.paimon.fs.Path;
2323
import org.apache.paimon.fs.local.LocalFileIO;
2424
import org.apache.paimon.utils.BlockingIterator;
25+
import org.apache.paimon.utils.TraceableFileIO;
2526

2627
import org.apache.flink.types.Row;
2728
import org.apache.flink.types.RowKind;
2829
import org.junit.jupiter.api.Test;
30+
import org.junit.jupiter.api.io.TempDir;
2931
import org.junit.jupiter.params.ParameterizedTest;
3032
import org.junit.jupiter.params.provider.Arguments;
3133
import org.junit.jupiter.params.provider.MethodSource;
@@ -41,6 +43,8 @@
4143
/** ITCase for deletion vector table. */
4244
public class DeletionVectorITCase extends CatalogITCaseBase {
4345

46+
@TempDir java.nio.file.Path tempExternalPath;
47+
4448
private static Stream<Arguments> parameters1() {
4549
// parameters: changelogProducer, dvBitmap64
4650
return Stream.of(
@@ -433,6 +437,7 @@ public void testIndexFileInDataFileDir() throws IOException {
433437
+ "'deletion-vectors.enabled' = 'true', "
434438
+ "'index-file-in-data-file-dir' = 'true')");
435439
sql("INSERT INTO IT (a, b) VALUES (1, 1)");
440+
assertThat(sql("SELECT * FROM IT")).containsExactly(Row.of(1, 1));
436441
Path path = getTableDirectory("IT");
437442
LocalFileIO fileIO = LocalFileIO.create();
438443
List<FileStatus> result = Arrays.asList(fileIO.listFiles(path, true));
@@ -445,9 +450,32 @@ public void testIndexFileInIndexDir() throws IOException {
445450
"CREATE TABLE IT (a INT PRIMARY KEY NOT ENFORCED, b INT) WITH ("
446451
+ "'deletion-vectors.enabled' = 'true')");
447452
sql("INSERT INTO IT (a, b) VALUES (1, 1)");
453+
assertThat(sql("SELECT * FROM IT")).containsExactly(Row.of(1, 1));
448454
Path path = getTableDirectory("IT");
449455
LocalFileIO fileIO = LocalFileIO.create();
450456
List<FileStatus> result = Arrays.asList(fileIO.listFiles(path, true));
451457
assertThat(result.toString()).contains("default.db/IT/index/index-");
452458
}
459+
460+
@Test
461+
public void testIndexFileInDataFileDirWithExternalPath() throws IOException {
462+
String externalPaths = TraceableFileIO.SCHEME + "://" + tempExternalPath.toString();
463+
sql(
464+
"CREATE TABLE IT (a INT PRIMARY KEY NOT ENFORCED, b INT) WITH ("
465+
+ "'deletion-vectors.enabled' = 'true', "
466+
+ "'index-file-in-data-file-dir' = 'true', "
467+
+ "'data-file.external-paths.strategy' = 'round-robin', "
468+
+ String.format("'data-file.external-paths' = '%s')", externalPaths));
469+
sql("INSERT INTO IT (a, b) VALUES (1, 1)");
470+
assertThat(sql("SELECT * FROM IT")).containsExactly(Row.of(1, 1));
471+
LocalFileIO fileIO = LocalFileIO.create();
472+
473+
Path path = getTableDirectory("IT");
474+
assertThat(Arrays.asList(fileIO.listFiles(path, true)).toString())
475+
.doesNotContain("default.db/IT/bucket-0/index-");
476+
477+
Path externalPath = new Path(externalPaths);
478+
assertThat(Arrays.asList(fileIO.listFiles(externalPath, true)).toString())
479+
.contains("bucket-0/index-");
480+
}
453481
}

0 commit comments

Comments
 (0)