-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save operational params in the same way with delta io (#1054)
# Description Currently writing "operationParameters" in commit info is misaligned with delta io connector. [Here](https://github.com/delta-io/delta/blob/36a7edb8cf507e713700ba827c5fb5ad32b9163e/core/src/main/scala/org/apache/spark/sql/delta/actions/actions.scala#L695) the sample of structure which is used in delta io. So the goal of this PR is to align with delta io approach and the PR do two thins: convert all values to string and delete keys with null values. # Related Issue(s) Closes [issue #1017](#1017) Co-authored-by: Ilya Moshkov <ilya.moshkov@exosfinancial.com>
- Loading branch information
Showing
3 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#[allow(dead_code)] | ||
mod fs_common; | ||
|
||
use deltalake::action::{Action, DeltaOperation, SaveMode}; | ||
|
||
use serde_json::{json, Value}; | ||
use std::error::Error; | ||
|
||
#[tokio::test] | ||
async fn test_operational_parameters() -> Result<(), Box<dyn Error>> { | ||
let path = "./tests/data/operational_parameters"; | ||
let mut table = fs_common::create_table(path, None).await; | ||
|
||
let add = fs_common::add(0); | ||
|
||
let operation = DeltaOperation::Write { | ||
mode: SaveMode::Append, | ||
partition_by: Some(vec!["some_partition".to_string()]), | ||
predicate: None, | ||
}; | ||
|
||
let mut tx = table.create_transaction(None); | ||
let actions = vec![Action::add(add.clone())]; | ||
tx.add_actions(actions); | ||
tx.commit(Some(operation), None).await.unwrap(); | ||
|
||
let commit_info = table.history(None).await?; | ||
let last_commit = &commit_info[commit_info.len() - 1]; | ||
|
||
assert_eq!(last_commit["operationParameters"]["mode"], json!("Append")); | ||
|
||
assert_eq!( | ||
last_commit["operationParameters"]["partitionBy"], | ||
json!("[\"some_partition\"]") | ||
); | ||
|
||
assert_eq!(last_commit["operationParameters"]["predicate"], Value::Null); | ||
|
||
Ok(()) | ||
} |