Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions crates/core/src/protocol/checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(),
Expand Down
19 changes: 9 additions & 10 deletions crates/core/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]
Expand Down
8 changes: 8 additions & 0 deletions crates/core/src/table/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<Add>> {
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<Add>> {
self.snapshot
.file_views(log_store, None)
Expand Down
22 changes: 14 additions & 8 deletions crates/core/src/writer/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -798,7 +802,7 @@ mod tests {
.into_iter()
.next()
.unwrap()
.stats
.stats()
.unwrap()
.parse::<serde_json::Value>()
.unwrap()
Expand Down Expand Up @@ -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);
Expand All @@ -861,7 +867,7 @@ mod tests {
.into_iter()
.next()
.unwrap()
.stats
.stats()
.unwrap()
.parse::<serde_json::Value>()
.unwrap()
Expand Down
32 changes: 20 additions & 12 deletions crates/core/src/writer/record_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -1170,7 +1176,7 @@ mod tests {
.into_iter()
.next()
.unwrap()
.stats
.stats()
.unwrap()
.parse::<serde_json::Value>()
.unwrap()
Expand Down Expand Up @@ -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);
Expand All @@ -1224,7 +1232,7 @@ mod tests {
.into_iter()
.next()
.unwrap()
.stats
.stats()
.unwrap()
.parse::<serde_json::Value>()
.unwrap()
Expand Down
Loading