@@ -44,7 +44,7 @@ use lance_file::{
4444} ;
4545use lance_io:: assert_io_eq;
4646use lance_table:: feature_flags;
47- use lance_table:: format:: BasePath ;
47+ use lance_table:: format:: { BasePath , Fragment } ;
4848use object_store:: ObjectStoreExt ;
4949
5050use crate :: index:: DatasetIndexExt ;
@@ -1412,6 +1412,51 @@ async fn test_restore_rejects_unknown_target_flags() {
14121412 assert ! ( matches!( error, Error :: NotSupported { .. } ) , "{error}" ) ;
14131413}
14141414
1415+ #[ tokio:: test]
1416+ async fn test_checkout_latest_rejects_unsupported_reader_before_caching ( ) {
1417+ let test_uri = TempStrDir :: default ( ) ;
1418+ let data = gen_batch ( )
1419+ . col ( "i" , array:: step :: < Int32Type > ( ) )
1420+ . into_reader_rows ( RowCount :: from ( 1 ) , BatchCount :: from ( 1 ) ) ;
1421+ let mut dataset = Dataset :: write ( data, & test_uri, None ) . await . unwrap ( ) ;
1422+ let original_version = dataset. version ( ) . version ;
1423+
1424+ let mut unsupported_manifest = dataset. manifest . as_ref ( ) . clone ( ) ;
1425+ unsupported_manifest. version += 1 ;
1426+ unsupported_manifest. reader_feature_flags |= feature_flags:: FLAG_UNKNOWN ;
1427+ unsupported_manifest. writer_feature_flags |= feature_flags:: FLAG_UNKNOWN ;
1428+ let location = write_manifest_file (
1429+ dataset. object_store . as_ref ( ) ,
1430+ dataset. commit_handler . as_ref ( ) ,
1431+ & dataset. base ,
1432+ & mut unsupported_manifest,
1433+ None ,
1434+ & ManifestWriteConfig {
1435+ auto_set_feature_flags : false ,
1436+ ..Default :: default ( )
1437+ } ,
1438+ dataset. manifest_location . naming_scheme ,
1439+ None ,
1440+ )
1441+ . await
1442+ . unwrap ( ) ;
1443+
1444+ let error = dataset. checkout_latest ( ) . await . unwrap_err ( ) ;
1445+ assert ! ( matches!( error, Error :: NotSupported { .. } ) , "{error}" ) ;
1446+ assert_eq ! ( dataset. version( ) . version, original_version) ;
1447+ assert ! (
1448+ dataset
1449+ . metadata_cache
1450+ . get_with_key( & ManifestKey {
1451+ version: location. version,
1452+ e_tag: location. e_tag. as_deref( ) ,
1453+ } )
1454+ . await
1455+ . is_none( ) ,
1456+ "unsupported manifest must not be cached"
1457+ ) ;
1458+ }
1459+
14151460#[ tokio:: test]
14161461async fn test_rle_v2_v23_write_and_append ( ) {
14171462 let test_uri = TempStrDir :: default ( ) ;
@@ -1792,6 +1837,52 @@ async fn test_deep_clone(
17921837 assert_eq ! ( count_files( store, & dst_root, "_deletions" ) . await , 0 ) ;
17931838}
17941839
1840+ #[ tokio:: test]
1841+ async fn test_deep_clone_rejects_unsupported_writer_before_copying ( ) {
1842+ let test_dir = TempStdDir :: default ( ) ;
1843+ let source_dir = test_dir. join ( "source" ) ;
1844+ let target_dir = test_dir. join ( "target" ) ;
1845+ let mut source = Dataset :: write (
1846+ gen_batch ( )
1847+ . col ( "id" , array:: step :: < Int32Type > ( ) )
1848+ . into_reader_rows ( RowCount :: from ( 32 ) , BatchCount :: from ( 1 ) ) ,
1849+ source_dir. to_str ( ) . unwrap ( ) ,
1850+ None ,
1851+ )
1852+ . await
1853+ . unwrap ( ) ;
1854+
1855+ let mut unsupported_manifest = source. manifest . as_ref ( ) . clone ( ) ;
1856+ unsupported_manifest. version += 1 ;
1857+ unsupported_manifest. writer_feature_flags |= feature_flags:: FLAG_UNKNOWN << 1 ;
1858+ write_manifest_file (
1859+ source. object_store . as_ref ( ) ,
1860+ source. commit_handler . as_ref ( ) ,
1861+ & source. base ,
1862+ & mut unsupported_manifest,
1863+ None ,
1864+ & ManifestWriteConfig {
1865+ auto_set_feature_flags : false ,
1866+ ..Default :: default ( )
1867+ } ,
1868+ source. manifest_location . naming_scheme ,
1869+ None ,
1870+ )
1871+ . await
1872+ . unwrap ( ) ;
1873+
1874+ let error = source
1875+ . deep_clone (
1876+ target_dir. to_str ( ) . unwrap ( ) ,
1877+ unsupported_manifest. version ,
1878+ None ,
1879+ )
1880+ . await
1881+ . unwrap_err ( ) ;
1882+ assert ! ( matches!( error, Error :: NotSupported { .. } ) ) ;
1883+ assert ! ( !target_dir. exists( ) ) ;
1884+ }
1885+
17951886#[ tokio:: test]
17961887async fn test_deep_clone_recognizes_ambiguous_commit_as_own ( ) {
17971888 use crate :: utils:: test:: { AmbiguousCommitHandler , AmbiguousFailure } ;
0 commit comments