22
33import io .whitefox .DeltaTestUtils ;
44import io .whitefox .core .*;
5+ import io .whitefox .core .services .exceptions .TableNotFound ;
56import io .whitefox .persistence .StorageManager ;
67import io .whitefox .persistence .memory .InMemoryStorageManager ;
78import java .util .Collections ;
@@ -38,7 +39,7 @@ public void listShares() throws ExecutionException, InterruptedException {
3839 }
3940
4041 @ Test
41- public void listSharesWithToken () throws ExecutionException , InterruptedException {
42+ public void listSharesWithToken () {
4243 var shares = List .of (createShare ("name" , "key" , Collections .emptyMap ()));
4344 StorageManager storageManager = new InMemoryStorageManager (shares );
4445 DeltaSharesService deltaSharesService =
@@ -49,7 +50,7 @@ public void listSharesWithToken() throws ExecutionException, InterruptedExceptio
4950 }
5051
5152 @ Test
52- public void listSchemasOfEmptyShare () throws ExecutionException , InterruptedException {
53+ public void listSchemasOfEmptyShare () {
5354 var shares = List .of (createShare ("name" , "key" , Collections .emptyMap ()));
5455 StorageManager storageManager = new InMemoryStorageManager (shares );
5556 DeltaSharesService deltaSharesService =
@@ -61,7 +62,7 @@ public void listSchemasOfEmptyShare() throws ExecutionException, InterruptedExce
6162 }
6263
6364 @ Test
64- public void listSchemas () throws ExecutionException , InterruptedException {
65+ public void listSchemas () {
6566 var shares = List .of (createShare (
6667 "name" , "key" , Map .of ("default" , new Schema ("default" , Collections .emptyList (), "name" ))));
6768 StorageManager storageManager = new InMemoryStorageManager (shares );
@@ -89,7 +90,7 @@ public void listSchemasOfUnknownShare() throws ExecutionException, InterruptedEx
8990 }
9091
9192 @ Test
92- public void listTables () throws ExecutionException , InterruptedException {
93+ public void listTables () {
9394 var shares = List .of (createShare (
9495 "name" ,
9596 "key" ,
@@ -114,7 +115,7 @@ public void listTables() throws ExecutionException, InterruptedException {
114115 }
115116
116117 @ Test
117- public void listAllTables () throws ExecutionException , InterruptedException {
118+ public void listAllTables () {
118119 var shares = List .of (createShare (
119120 "name" ,
120121 "key" ,
@@ -224,4 +225,51 @@ public void tableMetadataNotFound() {
224225 var resultTable = deltaSharesService .getTableMetadata ("name" , "default" , "tableNotFound" , null );
225226 Assertions .assertTrue (resultTable .isEmpty ());
226227 }
228+
229+ @ Test
230+ public void queryExistingTable () {
231+ var shares = List .of (createShare (
232+ "name" ,
233+ "key" ,
234+ Map .of (
235+ "default" ,
236+ new Schema (
237+ "default" ,
238+ List .of (new SharedTable (
239+ "partitioned-delta-table" ,
240+ "default" ,
241+ "name" ,
242+ DeltaTestUtils .deltaTable ("partitioned-delta-table" ))),
243+ "name" ))));
244+ StorageManager storageManager = new InMemoryStorageManager (shares );
245+ DeltaSharesService deltaSharesService =
246+ new DeltaSharesServiceImpl (storageManager , 100 , loader , fileSignerFactory );
247+ var resultTable = deltaSharesService .queryTable (
248+ "name" ,
249+ "default" ,
250+ "partitioned-delta-table" ,
251+ new ReadTableRequest .ReadTableCurrentVersion (
252+ Optional .empty (), Optional .empty (), Optional .empty ()));
253+ Assertions .assertEquals (9 , resultTable .files ().size ());
254+ }
255+
256+ @ Test
257+ public void queryNonExistingTable () {
258+ var shares = List .of (createShare (
259+ "name" ,
260+ "key" ,
261+ Map .of (
262+ "default" ,
263+ new Schema (
264+ "default" ,
265+ List .of (new SharedTable (
266+ "table1" , "default" , "name" , DeltaTestUtils .deltaTable ("location1" ))),
267+ "name" ))));
268+ StorageManager storageManager = new InMemoryStorageManager (shares );
269+ DeltaSharesService deltaSharesService =
270+ new DeltaSharesServiceImpl (storageManager , 100 , loader , fileSignerFactory );
271+ Assertions .assertThrows (
272+ TableNotFound .class ,
273+ () -> deltaSharesService .queryTable ("name" , "default" , "tableNotFound" , null ));
274+ }
227275}
0 commit comments