@@ -284,6 +284,50 @@ public void checkForGet_WithSecondaryIndexInSerializable_ShouldThrowIllegalArgum
284284 .isInstanceOf (IllegalArgumentException .class );
285285 }
286286
287+ @ Test
288+ public void
289+ checkForGet_WithIndexKeyUsingPartitionKeyInSerializable_ShouldNotThrowException () {
290+ // Arrange
291+ TableMetadata metadata =
292+ TableMetadata .newBuilder ()
293+ .addColumn ("pk" , DataType .INT )
294+ .addColumn ("col" , DataType .INT )
295+ .addPartitionKey ("pk" )
296+ .addSecondaryIndex ("pk" )
297+ .build ();
298+ when (tableMetadata .getTableMetadata ()).thenReturn (metadata );
299+
300+ Get get = Get .newBuilder ().namespace ("ns" ).table ("tbl" ).indexKey (Key .ofInt ("pk" , 100 )).build ();
301+ TransactionContext context =
302+ new TransactionContext ("txId" , null , Isolation .SERIALIZABLE , false , false );
303+
304+ // Act Assert
305+ assertThatCode (() -> checker .check (get , context )).doesNotThrowAnyException ();
306+ }
307+
308+ @ Test
309+ public void
310+ checkForGet_WithIndexKeyUsingClusteringKeyInSerializable_ShouldNotThrowException () {
311+ // Arrange
312+ TableMetadata metadata =
313+ TableMetadata .newBuilder ()
314+ .addColumn ("pk" , DataType .INT )
315+ .addColumn ("ck" , DataType .INT )
316+ .addColumn ("col" , DataType .INT )
317+ .addPartitionKey ("pk" )
318+ .addClusteringKey ("ck" )
319+ .addSecondaryIndex ("ck" )
320+ .build ();
321+ when (tableMetadata .getTableMetadata ()).thenReturn (metadata );
322+
323+ Get get = Get .newBuilder ().namespace ("ns" ).table ("tbl" ).indexKey (Key .ofInt ("ck" , 100 )).build ();
324+ TransactionContext context =
325+ new TransactionContext ("txId" , null , Isolation .SERIALIZABLE , false , false );
326+
327+ // Act Assert
328+ assertThatCode (() -> checker .check (get , context )).doesNotThrowAnyException ();
329+ }
330+
287331 @ Test
288332 public void checkForGet_ValidGet_ShouldNotThrowException () {
289333 // Arrange
@@ -402,6 +446,52 @@ public void checkForScan_WithSecondaryIndexInSerializable_ShouldThrowIllegalArgu
402446 .isInstanceOf (IllegalArgumentException .class );
403447 }
404448
449+ @ Test
450+ public void
451+ checkForScan_WithIndexKeyUsingPartitionKeyInSerializable_ShouldNotThrowException () {
452+ // Arrange
453+ TableMetadata metadata =
454+ TableMetadata .newBuilder ()
455+ .addColumn ("pk" , DataType .INT )
456+ .addColumn ("col" , DataType .INT )
457+ .addPartitionKey ("pk" )
458+ .addSecondaryIndex ("pk" )
459+ .build ();
460+ when (tableMetadata .getTableMetadata ()).thenReturn (metadata );
461+
462+ Scan scan =
463+ Scan .newBuilder ().namespace ("ns" ).table ("tbl" ).indexKey (Key .ofInt ("pk" , 100 )).build ();
464+ TransactionContext context =
465+ new TransactionContext ("txId" , null , Isolation .SERIALIZABLE , false , false );
466+
467+ // Act Assert
468+ assertThatCode (() -> checker .check (scan , context )).doesNotThrowAnyException ();
469+ }
470+
471+ @ Test
472+ public void
473+ checkForScan_WithIndexKeyUsingClusteringKeyInSerializable_ShouldNotThrowException () {
474+ // Arrange
475+ TableMetadata metadata =
476+ TableMetadata .newBuilder ()
477+ .addColumn ("pk" , DataType .INT )
478+ .addColumn ("ck" , DataType .INT )
479+ .addColumn ("col" , DataType .INT )
480+ .addPartitionKey ("pk" )
481+ .addClusteringKey ("ck" )
482+ .addSecondaryIndex ("ck" )
483+ .build ();
484+ when (tableMetadata .getTableMetadata ()).thenReturn (metadata );
485+
486+ Scan scan =
487+ Scan .newBuilder ().namespace ("ns" ).table ("tbl" ).indexKey (Key .ofInt ("ck" , 100 )).build ();
488+ TransactionContext context =
489+ new TransactionContext ("txId" , null , Isolation .SERIALIZABLE , false , false );
490+
491+ // Act Assert
492+ assertThatCode (() -> checker .check (scan , context )).doesNotThrowAnyException ();
493+ }
494+
405495 @ Test
406496 public void
407497 checkForScan_ScanAllWithConditionOnIndexedColumnInSerializable_ShouldThrowIllegalArgumentException () {
0 commit comments