Skip to content

Commit 87ad078

Browse files
authored
Merge branch 'main' into ctty/tx-commit
2 parents 93bffe9 + 40b055a commit 87ad078

File tree

4 files changed

+68
-3
lines changed

4 files changed

+68
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/catalog/rest/src/client.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,18 @@ impl HttpClient {
158158
.map(|(k, v)| (k.as_str(), v.as_str())),
159159
);
160160

161-
let auth_req = self
161+
let mut auth_req = self
162162
.request(Method::POST, &self.token_endpoint)
163163
.form(&params)
164164
.build()?;
165+
// extra headers add content-type application/json header it's necessary to override it with proper type
166+
// note that form call doesn't add content-type header if already present
167+
auth_req.headers_mut().insert(
168+
http::header::CONTENT_TYPE,
169+
http::HeaderValue::from_static("application/x-www-form-urlencoded"),
170+
);
165171
let auth_url = auth_req.url().clone();
166-
let auth_resp = self.execute(auth_req).await?;
172+
let auth_resp = self.client.execute(auth_req).await?;
167173

168174
let auth_res: TokenResponse = if auth_resp.status() == StatusCode::OK {
169175
let text = auth_resp

crates/iceberg/src/transaction/append.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ impl<'a> FastAppendAction<'a> {
7272
Ok(self)
7373
}
7474

75+
/// Set snapshot summary properties.
76+
pub fn set_snapshot_properties(
77+
&mut self,
78+
snapshot_properties: HashMap<String, String>,
79+
) -> Result<&mut Self> {
80+
self.snapshot_produce_action
81+
.set_snapshot_properties(snapshot_properties)?;
82+
Ok(self)
83+
}
84+
7585
/// Adds existing parquet files
7686
///
7787
/// Note: This API is not yet fully supported in version 0.5.x.
@@ -211,6 +221,8 @@ impl SnapshotProduceOperation for FastAppendOperation {
211221

212222
#[cfg(test)]
213223
mod tests {
224+
use std::collections::HashMap;
225+
214226
use crate::scan::tests::TableTestFixture;
215227
use crate::spec::{
216228
DataContentType, DataFileBuilder, DataFileFormat, Literal, MAIN_BRANCH, Struct,
@@ -228,6 +240,44 @@ mod tests {
228240
assert!(action.apply().await.is_err());
229241
}
230242

243+
#[tokio::test]
244+
async fn test_set_snapshot_properties() {
245+
let table = make_v2_minimal_table();
246+
let tx = Transaction::new(&table);
247+
let mut action = tx.fast_append(None, vec![]).unwrap();
248+
249+
let mut snapshot_properties = HashMap::new();
250+
snapshot_properties.insert("key".to_string(), "val".to_string());
251+
action.set_snapshot_properties(snapshot_properties).unwrap();
252+
let data_file = DataFileBuilder::default()
253+
.content(DataContentType::Data)
254+
.file_path("test/1.parquet".to_string())
255+
.file_format(DataFileFormat::Parquet)
256+
.file_size_in_bytes(100)
257+
.record_count(1)
258+
.partition_spec_id(table.metadata().default_partition_spec_id())
259+
.partition(Struct::from_iter([Some(Literal::long(300))]))
260+
.build()
261+
.unwrap();
262+
action.add_data_files(vec![data_file]).unwrap();
263+
let tx = action.apply().await.unwrap();
264+
265+
// Check customized properties is contained in snapshot summary properties.
266+
let new_snapshot = if let TableUpdate::AddSnapshot { snapshot } = &tx.updates[0] {
267+
snapshot
268+
} else {
269+
unreachable!()
270+
};
271+
assert_eq!(
272+
new_snapshot
273+
.summary()
274+
.additional_properties
275+
.get("key")
276+
.unwrap(),
277+
"val"
278+
);
279+
}
280+
231281
#[tokio::test]
232282
async fn test_fast_append_action() {
233283
let table = make_v2_minimal_table();

crates/iceberg/src/transaction/snapshot.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ impl<'a> SnapshotProduceAction<'a> {
122122
Ok(())
123123
}
124124

125+
/// Set snapshot summary properties.
126+
pub fn set_snapshot_properties(
127+
&mut self,
128+
snapshot_properties: HashMap<String, String>,
129+
) -> Result<&mut Self> {
130+
self.snapshot_properties = snapshot_properties;
131+
Ok(self)
132+
}
133+
125134
/// Add data files to the snapshot.
126135
pub fn add_data_files(
127136
&mut self,

0 commit comments

Comments
 (0)