danking opened a new issue, #1145:
URL: https://github.com/apache/iceberg-rust/issues/1145

   ### Apache Iceberg Rust version
   
   0.4.0 (latest version)
   
   ### Describe the bug
   
   I'm using a (relatively new) Iceberg Rest catalog. I expected the following 
to simply return an empty vector but instead I received an error.
   
   ```
   Error: Unexpected => Can't scan table without snapshots
   ```
   
   Indeed this table appears to have no snapshots yet. Is this expected 
behavior or should Iceberg Rust return an empty scan?
   
   ```rust
       let catalog = RestCatalog::new(
           RestCatalogConfig::builder()
               .uri("http://localhost:4279/iceberg".to_owned())
               .warehouse("file://".to_string())
               .props(
                   [("token".to_owned(), secret.to_owned())]
                       .into_iter()
                       .collect(),
               )
               .build(),
       );
       let namespace = NamespaceIdent::from_strs(["clay-husky-438588", "xx"])?;
       let resp = catalog.create_namespace(&namespace, HashMap::new()).await;
       let table_ident = TableIdent::new(namespace.clone(), "table".to_owned());
       catalog
           .create_table(
               &namespace,
               TableCreation::builder()
                   .name("table".to_owned())
                   .schema(Schema::builder().build()?)
                   .build(),
           )
           .await?
       let table = catalog.load_table(&table_ident).await?;
       let stream = table
           .scan()
           .build()?
           .to_arrow()
           .await?;
       let _data: Vec<_> = stream.try_collect().await?;
   ```
   
   FWIW, PyIceberg returns an empty scan using the same catalog:
   
   ```python
   catalog.create_namespace_if_not_exists(('clay-husky-438588', 'xx'))
   table = catalog.create_table(
       "clay-husky-438588.table02", schema=pa.schema([('x', pa.int64())])
   )
   table.scan().to_pandas()
   ```
   
   Error:
   ```
   Error: Unexpected => Can't scan table without snapshots
   
   Backtrace:
      0: std::backtrace_rs::backtrace::libunwind::trace
                at 
/rustc/a0d98ff0e5b6e1f2c63fd26f68484792621b235c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
      1: std::backtrace_rs::backtrace::trace_unsynchronized
                at 
/rustc/a0d98ff0e5b6e1f2c63fd26f68484792621b235c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
      2: std::backtrace::Backtrace::create
                at 
/rustc/a0d98ff0e5b6e1f2c63fd26f68484792621b235c/library/std/src/backtrace.rs:331:13
      3: iceberg::error::Error::new
                at 
/Users/danielking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/iceberg-0.4.0/src/error.rs:206:24
      4: iceberg::scan::TableScanBuilder::build::{{closure}}
                at 
/Users/danielking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/iceberg-0.4.0/src/scan.rs:208:21
      5: core::option::Option<T>::ok_or_else
                at 
/Users/danielking/.rustup/toolchains/nightly-2024-11-01-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:1276:25
      6: iceberg::scan::TableScanBuilder::build
                at 
/Users/danielking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/iceberg-0.4.0/src/scan.rs:203:21
      7: iceberg::main::{{closure}}
                at ./examples/src/bin/iceberg.rs:53:18
      8: <core::pin::Pin<P> as core::future::future::Future>::poll
                at 
/Users/danielking/.rustup/toolchains/nightly-2024-11-01-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/future.rs:123:9
      9: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
                at 
/Users/danielking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.44.0/src/runtime/park.rs:284:60
     10: tokio::task::coop::with_budget
                at 
/Users/danielking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.44.0/src/task/coop/mod.rs:167:5
     11: tokio::task::coop::budget
                at 
/Users/danielking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.44.0/src/task/coop/mod.rs:133:5
     12: tokio::runtime::park::CachedParkThread::block_on
                at 
/Users/danielking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.44.0/src/runtime/park.rs:284:31
     13: tokio::runtime::context::blocking::BlockingRegionGuard::block_on
                at 
/Users/danielking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.44.0/src/runtime/context/blocking.rs:66:9
     14: 
tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}
                at 
/Users/danielking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.44.0/src/runtime/scheduler/multi_thread/mod.rs:87:13
     15: tokio::runtime::context::runtime::enter_runtime
                at 
/Users/danielking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.44.0/src/runtime/context/runtime.rs:65:16
     16: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
                at 
/Users/danielking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.44.0/src/runtime/scheduler/multi_thread/mod.rs:86:9
     17: tokio::runtime::runtime::Runtime::block_on_inner
                at 
/Users/danielking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.44.0/src/runtime/runtime.rs:370:45
     18: tokio::runtime::runtime::Runtime::block_on
                at 
/Users/danielking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.44.0/src/runtime/runtime.rs:340:13
     19: iceberg::main
                at ./examples/src/bin/iceberg.rs:62:5
     20: core::ops::function::FnOnce::call_once
                at 
/Users/danielking/.rustup/toolchains/nightly-2024-11-01-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
     21: std::sys::backtrace::__rust_begin_short_backtrace
                at 
/Users/danielking/.rustup/toolchains/nightly-2024-11-01-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs:154:18
     22: std::rt::lang_start::{{closure}}
                at 
/Users/danielking/.rustup/toolchains/nightly-2024-11-01-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/rt.rs:195:18
     23: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for 
&F>::call_once
                at 
/rustc/a0d98ff0e5b6e1f2c63fd26f68484792621b235c/library/core/src/ops/function.rs:284:13
     24: std::panicking::try::do_call
                at 
/rustc/a0d98ff0e5b6e1f2c63fd26f68484792621b235c/library/std/src/panicking.rs:557:40
     25: std::panicking::try
                at 
/rustc/a0d98ff0e5b6e1f2c63fd26f68484792621b235c/library/std/src/panicking.rs:520:19
     26: std::panic::catch_unwind
                at 
/rustc/a0d98ff0e5b6e1f2c63fd26f68484792621b235c/library/std/src/panic.rs:358:14
     27: std::rt::lang_start_internal::{{closure}}
                at 
/rustc/a0d98ff0e5b6e1f2c63fd26f68484792621b235c/library/std/src/rt.rs:174:48
     28: std::panicking::try::do_call
                at 
/rustc/a0d98ff0e5b6e1f2c63fd26f68484792621b235c/library/std/src/panicking.rs:557:40
     29: std::panicking::try
                at 
/rustc/a0d98ff0e5b6e1f2c63fd26f68484792621b235c/library/std/src/panicking.rs:520:19
     30: std::panic::catch_unwind
                at 
/rustc/a0d98ff0e5b6e1f2c63fd26f68484792621b235c/library/std/src/panic.rs:358:14
     31: std::rt::lang_start_internal
                at 
/rustc/a0d98ff0e5b6e1f2c63fd26f68484792621b235c/library/std/src/rt.rs:174:20
     32: std::rt::lang_start
                at 
/Users/danielking/.rustup/toolchains/nightly-2024-11-01-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/rt.rs:194:17
     33: _main
   
   ```
   
   ### To Reproduce
   
   See above
   
   ### Expected behavior
   
   I expected an empty result.
   
   ### Willingness to contribute
   
   I would be willing to contribute a fix for this bug with guidance from the 
Iceberg community


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to