Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit action field optionality #380

Merged
merged 1 commit into from
Sep 6, 2021
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
2 changes: 1 addition & 1 deletion python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct RawDeltaTableMetaData {
#[pyo3(get)]
partition_columns: Vec<String>,
#[pyo3(get)]
created_time: deltalake::DeltaDataTypeTimestamp,
created_time: Option<deltalake::DeltaDataTypeTimestamp>,
#[pyo3(get)]
configuration: HashMap<String, Option<String>>,
}
Expand Down
17 changes: 10 additions & 7 deletions rust/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ pub struct MetaData {
/// An array containing the names of columns by which the data should be partitioned
pub partition_columns: Vec<String>,
/// The time when this metadata action is created, in milliseconds since the Unix epoch
pub created_time: DeltaDataTypeTimestamp,
pub created_time: Option<DeltaDataTypeTimestamp>,
/// A map containing configuration options for the table
pub configuration: HashMap<String, Option<String>>,
}
Expand Down Expand Up @@ -459,9 +459,10 @@ impl MetaData {
.clone();
}
"createdTime" => {
re.created_time = record
.get_long(i)
.map_err(|_| gen_action_type_error("metaData", "createdTime", "long"))?;
re.created_time =
Some(record.get_long(i).map_err(|_| {
gen_action_type_error("metaData", "createdTime", "long")
})?);
}
"configuration" => {
let configuration_map = record
Expand Down Expand Up @@ -537,7 +538,7 @@ pub struct Remove {
/// The path of the file that is removed from the table.
pub path: String,
/// The timestamp when the remove was added to table state.
pub deletion_timestamp: DeltaDataTypeTimestamp,
pub deletion_timestamp: Option<DeltaDataTypeTimestamp>,
fvaleye marked this conversation as resolved.
Show resolved Hide resolved
/// Whether data is changed by the remove. A table optimize will report this as false for
/// example, since it adds and removes files by combining many files into one.
pub data_change: bool,
Expand All @@ -554,6 +555,8 @@ pub struct Remove {
impl Remove {
fn from_parquet_record(record: &parquet::record::Row) -> Result<Self, ActionError> {
let mut re = Self {
data_change: true,
extended_file_metadata: Some(false),
..Default::default()
};

Expand All @@ -576,9 +579,9 @@ impl Remove {
})?);
}
"deletionTimestamp" => {
re.deletion_timestamp = record.get_long(i).map_err(|_| {
re.deletion_timestamp = Some(record.get_long(i).map_err(|_| {
gen_action_type_error("remove", "deletionTimestamp", "long")
})?;
})?);
}
"partitionValues" => match record.get_map(i) {
Ok(_) => {
Expand Down
6 changes: 3 additions & 3 deletions rust/src/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pub struct DeltaTableMetaData {
/// An array containing the names of columns by which the data should be partitioned
pub partition_columns: Vec<String>,
/// The time when this metadata action is created, in milliseconds since the Unix epoch
pub created_time: DeltaDataTypeTimestamp,
pub created_time: Option<DeltaDataTypeTimestamp>,
/// table properties
pub configuration: HashMap<String, Option<String>>,
}
Expand All @@ -226,7 +226,7 @@ impl DeltaTableMetaData {
format: format.unwrap_or_default(),
schema,
partition_columns,
created_time: Utc::now().timestamp_millis(),
created_time: Some(Utc::now().timestamp_millis()),
configuration,
}
}
Expand Down Expand Up @@ -919,7 +919,7 @@ impl DeltaTable {
Ok(self
.get_tombstones()
.iter()
.filter(|tombstone| tombstone.deletion_timestamp < delete_before_timestamp)
.filter(|tombstone| tombstone.deletion_timestamp.unwrap_or(0) < delete_before_timestamp)
.map(|tombstone| tombstone.path.as_str())
.collect::<HashSet<_>>())
}
Expand Down
2 changes: 1 addition & 1 deletion rust/tests/azure_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ mod azure {
deltalake::action::Remove {
path: "part-00006-63ce9deb-bc0f-482d-b9a1-7e717b67f294-c000.snappy.parquet"
.to_string(),
deletion_timestamp: 1587968596250,
deletion_timestamp: Some(1587968596250),
data_change: true,
..Default::default()
}
Expand Down
5 changes: 3 additions & 2 deletions rust/tests/read_delta_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ async fn read_delta_2_0_table_without_version() {
tombstones[0],
deltalake::action::Remove {
path: "part-00000-512e1537-8aaa-4193-b8b4-bef3de0de409-c000.snappy.parquet".to_string(),
deletion_timestamp: 1564524298213,
deletion_timestamp: Some(1564524298213),
data_change: false,
extended_file_metadata: Some(false),
..Default::default()
}
);
Expand Down Expand Up @@ -134,7 +135,7 @@ async fn read_delta_8_0_table_without_version() {
tombstones[0],
deltalake::action::Remove {
path: "part-00001-911a94a2-43f6-4acb-8620-5e68c2654989-c000.snappy.parquet".to_string(),
deletion_timestamp: 1615043776198,
deletion_timestamp: Some(1615043776198),
data_change: true,
extended_file_metadata: Some(true),
partition_values: Some(HashMap::new()),
Expand Down
3 changes: 2 additions & 1 deletion rust/tests/read_simple_table_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ async fn read_simple_table() {
tombstones[0],
deltalake::action::Remove {
path: "part-00006-63ce9deb-bc0f-482d-b9a1-7e717b67f294-c000.snappy.parquet".to_string(),
deletion_timestamp: 1587968596250,
deletion_timestamp: Some(1587968596250),
data_change: true,
extended_file_metadata: None,
..Default::default()
}
);
Expand Down
4 changes: 2 additions & 2 deletions rust/tests/s3_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mod s3 {
deltalake::action::Remove {
path: "part-00006-63ce9deb-bc0f-482d-b9a1-7e717b67f294-c000.snappy.parquet"
.to_string(),
deletion_timestamp: 1587968596250,
deletion_timestamp: Some(1587968596250),
data_change: true,
..Default::default()
}
Expand Down Expand Up @@ -77,7 +77,7 @@ mod s3 {
deltalake::action::Remove {
path: "part-00006-63ce9deb-bc0f-482d-b9a1-7e717b67f294-c000.snappy.parquet"
.to_string(),
deletion_timestamp: 1587968596250,
deletion_timestamp: Some(1587968596250),
data_change: true,
..Default::default()
}
Expand Down
2 changes: 1 addition & 1 deletion rust/tests/write_exploration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ pub fn create_remove(path: String) -> Remove {

Remove {
path,
deletion_timestamp: deletion_timestamp,
deletion_timestamp: Some(deletion_timestamp),
data_change: true,
extended_file_metadata: Some(false),
..Default::default()
Expand Down