diff --git a/crates/core/src/protocol/checkpoints.rs b/crates/core/src/protocol/checkpoints.rs index 6352ca90fc..e050ea8948 100644 --- a/crates/core/src/protocol/checkpoints.rs +++ b/crates/core/src/protocol/checkpoints.rs @@ -677,7 +677,12 @@ mod tests { count, "Expected {count} transactions" ); - let pre_checkpoint_actions = table.snapshot()?.file_actions(&table.log_store).await?; + let pre_checkpoint_actions: Vec<_> = table + .snapshot()? + .snapshot() + .file_views(&table.log_store, None) + .try_collect() + .await?; let before = table.version(); let res = create_checkpoint(&table, None).await; @@ -692,7 +697,12 @@ mod tests { "Why on earth did a checkpoint creata version?" ); - let post_checkpoint_actions = table.snapshot()?.file_actions(&table.log_store).await?; + let post_checkpoint_actions: Vec<_> = table + .snapshot()? + .snapshot() + .file_views(&table.log_store, None) + .try_collect() + .await?; assert_eq!( pre_checkpoint_actions.len(), diff --git a/crates/core/src/protocol/mod.rs b/crates/core/src/protocol/mod.rs index d4b7bb8b28..5ca640d4f8 100644 --- a/crates/core/src/protocol/mod.rs +++ b/crates/core/src/protocol/mod.rs @@ -710,6 +710,7 @@ mod tests { use arrow::compute::sort_to_indices; use arrow::datatypes::{DataType, Date32Type, Field, Fields, TimestampMicrosecondType}; use arrow::record_batch::RecordBatch; + use futures::TryStreamExt; use pretty_assertions::assert_eq; use std::path::Path; use std::sync::Arc; @@ -1116,16 +1117,14 @@ mod tests { let mut table = crate::open_table(table_uri).await.unwrap(); table.load().await.unwrap(); - assert_eq!( - 2, - table - .snapshot() - .unwrap() - .file_actions(&table.log_store) - .await - .unwrap() - .len() - ); + let snapshot = table.snapshot().unwrap().snapshot(); + let files: Vec<_> = snapshot + .file_views(&table.log_store, None) + .try_collect() + .await + .unwrap(); + + assert_eq!(2, files.len()); } #[tokio::test] diff --git a/crates/core/src/table/state.rs b/crates/core/src/table/state.rs index a6708b5857..87a0f7614b 100644 --- a/crates/core/src/table/state.rs +++ b/crates/core/src/table/state.rs @@ -140,12 +140,20 @@ impl DeltaTableState { /// Full list of add actions representing all parquet files that are part of the current /// delta table state. + #[deprecated( + since = "0.29.1", + note = "Use `.snapshot().file_views(log_store, predicate)` instead." + )] pub async fn file_actions(&self, log_store: &dyn LogStore) -> DeltaResult> { self.file_actions_iter(log_store).try_collect().await } /// Full list of add actions representing all parquet files that are part of the current /// delta table state. + #[deprecated( + since = "0.29.1", + note = "Use `.snapshot().file_views(log_store, predicate)` instead." + )] pub fn file_actions_iter(&self, log_store: &dyn LogStore) -> BoxStream<'_, DeltaResult> { self.snapshot .file_views(log_store, None) diff --git a/crates/core/src/writer/json.rs b/crates/core/src/writer/json.rs index 6c3fcd8208..ed02f66b71 100644 --- a/crates/core/src/writer/json.rs +++ b/crates/core/src/writer/json.rs @@ -474,6 +474,8 @@ mod tests { use super::*; use arrow_schema::ArrowError; + #[cfg(feature = "datafusion")] + use futures::TryStreamExt; use parquet::file::reader::FileReader; use parquet::file::serialized_reader::SerializedFileReader; use std::fs::File; @@ -784,10 +786,12 @@ mod tests { writer.write(vec![data]).await.unwrap(); writer.flush_and_commit(&mut table).await.unwrap(); assert_eq!(table.version(), Some(1)); - let add_actions = table - .state + let add_actions: Vec<_> = table + .snapshot() .unwrap() - .file_actions(&table.log_store) + .snapshot() + .file_views(&table.log_store, None) + .try_collect() .await .unwrap(); assert_eq!(add_actions.len(), 1); @@ -798,7 +802,7 @@ mod tests { .into_iter() .next() .unwrap() - .stats + .stats() .unwrap() .parse::() .unwrap() @@ -847,10 +851,12 @@ mod tests { writer.write(vec![data]).await.unwrap(); writer.flush_and_commit(&mut table).await.unwrap(); assert_eq!(table.version(), Some(1)); - let add_actions = table - .state + let add_actions: Vec<_> = table + .snapshot() .unwrap() - .file_actions(&table.log_store) + .snapshot() + .file_views(&table.log_store, None) + .try_collect() .await .unwrap(); assert_eq!(add_actions.len(), 1); @@ -861,7 +867,7 @@ mod tests { .into_iter() .next() .unwrap() - .stats + .stats() .unwrap() .parse::() .unwrap() diff --git a/crates/core/src/writer/record_batch.rs b/crates/core/src/writer/record_batch.rs index 4e49dbd7dc..db1de9f2b3 100644 --- a/crates/core/src/writer/record_batch.rs +++ b/crates/core/src/writer/record_batch.rs @@ -527,16 +527,20 @@ fn lexsort_to_indices(arrays: &[ArrayRef]) -> UInt32Array { #[cfg(test)] mod tests { - use super::*; - use crate::operations::create::CreateBuilder; - use crate::writer::test_utils::*; - use crate::{DeltaOps, DeltaResult}; use arrow::json::ReaderBuilder; use arrow_array::{Int32Array, RecordBatch, StringArray}; use arrow_schema::{DataType, Field, Schema as ArrowSchema}; use delta_kernel::schema::StructType; + #[cfg(feature = "datafusion")] + use futures::TryStreamExt; use std::path::Path; + use crate::operations::create::CreateBuilder; + use crate::writer::test_utils::*; + use crate::{DeltaOps, DeltaResult}; + + use super::*; + #[tokio::test] async fn test_buffer_len_includes_unflushed_row_group() { let table_dir = tempfile::tempdir().unwrap(); @@ -1156,10 +1160,12 @@ mod tests { writer.write(batch).await.unwrap(); writer.flush_and_commit(&mut table).await.unwrap(); assert_eq!(table.version(), Some(1)); - let add_actions = table - .state + let add_actions: Vec<_> = table + .snapshot() .unwrap() - .file_actions(&table.log_store) + .snapshot() + .file_views(&table.log_store, None) + .try_collect() .await .unwrap(); assert_eq!(add_actions.len(), 1); @@ -1170,7 +1176,7 @@ mod tests { .into_iter() .next() .unwrap() - .stats + .stats() .unwrap() .parse::() .unwrap() @@ -1210,10 +1216,12 @@ mod tests { writer.write(batch).await.unwrap(); writer.flush_and_commit(&mut table).await.unwrap(); assert_eq!(table.version(), Some(1)); - let add_actions = table - .state + let add_actions: Vec<_> = table + .snapshot() .unwrap() - .file_actions(&table.log_store) + .snapshot() + .file_views(&table.log_store, None) + .try_collect() .await .unwrap(); assert_eq!(add_actions.len(), 1); @@ -1224,7 +1232,7 @@ mod tests { .into_iter() .next() .unwrap() - .stats + .stats() .unwrap() .parse::() .unwrap()