Skip to content

Commit d4c0488

Browse files
Merge branch 'main' into phillip/250509-predicate-fix
2 parents c7d9b01 + 71b1307 commit d4c0488

File tree

9 files changed

+47
-8
lines changed

9 files changed

+47
-8
lines changed

.github/workflows/ci_typos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ jobs:
4242
steps:
4343
- uses: actions/checkout@v4
4444
- name: Check typos
45-
uses: crate-ci/typos@v1.31.1
45+
uses: crate-ci/typos@v1.32.0

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/python/Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/iceberg/src/arrow/schema.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,5 +1688,22 @@ mod tests {
16881688
]));
16891689
assert_eq!(arrow_type, type_to_arrow_type(&iceberg_type).unwrap());
16901690
}
1691+
1692+
// test dictionary type
1693+
{
1694+
let arrow_type =
1695+
DataType::Dictionary(Box::new(DataType::Int32), Box::new(DataType::Int8));
1696+
let iceberg_type = Type::Primitive(PrimitiveType::Int);
1697+
assert_eq!(
1698+
iceberg_type,
1699+
arrow_type_to_type(&arrow_type).unwrap(),
1700+
"Expected dictionary conversion to use the contained value"
1701+
);
1702+
1703+
let arrow_type =
1704+
DataType::Dictionary(Box::new(DataType::Utf8), Box::new(DataType::Boolean));
1705+
let iceberg_type = Type::Primitive(PrimitiveType::Boolean);
1706+
assert_eq!(iceberg_type, arrow_type_to_type(&arrow_type).unwrap());
1707+
}
16911708
}
16921709
}

crates/iceberg/src/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ pub type Result<T> = std::result::Result<T, Error>;
2828
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
2929
#[non_exhaustive]
3030
pub enum ErrorKind {
31+
/// The operation was rejected because the system is not in a state required for the operation’s execution.
32+
PreconditionFailed,
33+
3134
/// Iceberg don't know what happened here, and no actions other than
3235
/// just returning it back. For example, iceberg returns an internal
3336
/// service error.
@@ -76,6 +79,7 @@ impl From<ErrorKind> for &'static str {
7679
ErrorKind::TableNotFound => "TableNotFound",
7780
ErrorKind::NamespaceAlreadyExists => "NamespaceAlreadyExists",
7881
ErrorKind::NamespaceNotFound => "NamespaceNotFound",
82+
ErrorKind::PreconditionFailed => "PreconditionFailed",
7983
}
8084
}
8185
}

crates/iceberg/src/puffin/blob.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use std::collections::HashMap;
1919

2020
/// A serialized form of a "compact" Theta sketch produced by the Apache DataSketches library.
2121
pub const APACHE_DATASKETCHES_THETA_V1: &str = "apache-datasketches-theta-v1";
22+
/// A serialized form of a deletion vector.
23+
pub const DELETION_VECTOR_V1: &str = "deletion-vector-v1";
2224

2325
/// The blob
2426
#[derive(Debug, PartialEq, Clone)]

crates/iceberg/src/puffin/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#![deny(missing_docs)]
2121

2222
mod blob;
23-
pub use blob::{Blob, APACHE_DATASKETCHES_THETA_V1};
23+
pub use blob::{Blob, APACHE_DATASKETCHES_THETA_V1, DELETION_VECTOR_V1};
2424

2525
mod compression;
2626
pub use compression::CompressionCodec;

crates/iceberg/src/transaction/append.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,15 @@ mod tests {
219219
use crate::transaction::Transaction;
220220
use crate::{TableRequirement, TableUpdate};
221221

222+
#[tokio::test]
223+
async fn test_empty_data_append_action() {
224+
let table = make_v2_minimal_table();
225+
let tx = Transaction::new(&table);
226+
let mut action = tx.fast_append(None, vec![]).unwrap();
227+
action.add_data_files(vec![]).unwrap();
228+
assert!(action.apply().await.is_err());
229+
}
230+
222231
#[tokio::test]
223232
async fn test_fast_append_action() {
224233
let table = make_v2_minimal_table();

crates/iceberg/src/transaction/snapshot.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ impl<'a> SnapshotProduceAction<'a> {
172172
// Write manifest file for added data files and return the ManifestFile for ManifestList.
173173
async fn write_added_manifest(&mut self) -> Result<ManifestFile> {
174174
let added_data_files = std::mem::take(&mut self.added_data_files);
175+
if added_data_files.is_empty() {
176+
return Err(Error::new(
177+
ErrorKind::PreconditionFailed,
178+
"No added data files found when write a manifest file",
179+
));
180+
}
181+
175182
let snapshot_id = self.snapshot_id;
176183
let format_version = self.tx.current_table.metadata().format_version();
177184
let manifest_entries = added_data_files.into_iter().map(|data_file| {

0 commit comments

Comments
 (0)