When retrieving the history of a DeltaTable using Rust, the version of each commit is not included. This is a proposal with code included to extend the CommitInfo struct.
The problem today
let history = match delta_table.history(limit).await {
Ok(vci) => {
vci
},
Err(_) => Vec::new() // empty
};
for h in history {
// Not able to get the version here
}
Proposal
This proposal makes a minor change to the CommitInfo-struct and how the function commit_infos(...) operates when mapping actions.
In core/src/kernel/models/action.rs extend the CommitInfo with:
/// The version of the commit - Note: Never included in the json
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<i64>,
And in core/src/kernel/snapshot/mod.rs expand line 253:255 from:
if let Action::CommitInfo(commit_info) = action {
return Ok::<_, DeltaTableError>(Some(commit_info));
}
To:
if let Action::CommitInfo(mut commit_info) = action {
commit_info.version = meta.location.commit_version();
return Ok::<_, DeltaTableError>(Some(commit_info));
}
_Note: If you are using the SQL-extended command DESCRIBE HISTORY table_name, the version is included._
Use Case
With this "minor" change, we are now able to include the version of each commit:
let history = match delta_table.history(limit).await {
Ok(vci) => {
vci
},
Err(_) => Vec::new() // empty
};
for h in history {
println("{}", h.version());
}
I am aware of the issue that this breaks some kind of responsibility of CommitInfo. It is no longer completely matching the JSON-response from the file itself.
Description
When retrieving the history of a
DeltaTable
using Rust, the version of each commit is not included. This is a proposal with code included to extend theCommitInfo
struct.The problem today
Proposal This proposal makes a minor change to the
CommitInfo
-struct and how the functioncommit_infos(...)
operates when mapping actions.In
core/src/kernel/models/action.rs
extend theCommitInfo
with:And in
core/src/kernel/snapshot/mod.rs
expand line253:255
from:To:
_Note: If you are using the SQL-extended command
DESCRIBE HISTORY table_name
, the version is included._Use Case
With this "minor" change, we are now able to include the version of each commit:
Related Issue(s) None