2222import org .apache .paimon .fs .Path ;
2323import org .apache .paimon .fs .local .LocalFileIO ;
2424import org .apache .paimon .utils .BlockingIterator ;
25+ import org .apache .paimon .utils .TraceableFileIO ;
2526
2627import org .apache .flink .types .Row ;
2728import org .apache .flink .types .RowKind ;
2829import org .junit .jupiter .api .Test ;
30+ import org .junit .jupiter .api .io .TempDir ;
2931import org .junit .jupiter .params .ParameterizedTest ;
3032import org .junit .jupiter .params .provider .Arguments ;
3133import org .junit .jupiter .params .provider .MethodSource ;
4143/** ITCase for deletion vector table. */
4244public 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