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

feat: expose create_add to the public #1482

Merged
merged 7 commits into from
Jun 28, 2023
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
6 changes: 6 additions & 0 deletions rust/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ impl From<ProtocolError> for DeltaTableError {
}
}

impl From<serde_json::Error> for DeltaTableError {
fn from(value: serde_json::Error) -> Self {
DeltaTableError::InvalidStatsJson { json_err: value }
}
}

impl DeltaTableError {
/// Crate a NotATable Error with message for given path.
pub fn not_a_table(path: impl AsRef<str>) -> Self {
Expand Down
1 change: 1 addition & 0 deletions rust/src/writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::DeltaTable;

pub use json::JsonWriter;
pub use record_batch::RecordBatchWriter;
pub use stats::create_add;

pub mod json;
pub mod record_batch;
Expand Down
5 changes: 3 additions & 2 deletions rust/src/writer/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ use parquet::{
use super::*;
use crate::action::{Add, ColumnValueStat, Stats};

pub(crate) fn create_add(
/// Creates an [`Add`] log action struct.
pub fn create_add(
partition_values: &HashMap<String, Option<String>>,
path: String,
size: i64,
file_metadata: &FileMetaData,
) -> Result<Add, DeltaWriterError> {
) -> Result<Add, DeltaTableError> {
let stats = stats_from_file_metadata(partition_values, file_metadata)?;
let stats_string = serde_json::to_string(&stats)?;

Expand Down