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(rust): support additional types for partition values #1170

Closed
wjones127 opened this issue Feb 22, 2023 · 1 comment · Fixed by #1180
Closed

feat(rust): support additional types for partition values #1170

wjones127 opened this issue Feb 22, 2023 · 1 comment · Fixed by #1180
Labels
binding/rust Issues for the Rust crate enhancement New feature or request good first issue Good for newcomers

Comments

@wjones127
Copy link
Collaborator

Description

We currently only support integers and strings for partition values. We should support the remaining types described at:

https://github.com/delta-io/delta/blob/master/PROTOCOL.md#partition-value-serialization

This is currently implemented in this function:

pub(crate) fn stringified_partition_value(
arr: &Arc<dyn Array>,
) -> Result<Option<String>, DeltaWriterError> {
let data_type = arr.data_type();
if arr.is_null(0) {
return Ok(None);
}
let s = match data_type {
DataType::Int8 => as_primitive_array::<Int8Type>(arr).value(0).to_string(),
DataType::Int16 => as_primitive_array::<Int16Type>(arr).value(0).to_string(),
DataType::Int32 => as_primitive_array::<Int32Type>(arr).value(0).to_string(),
DataType::Int64 => as_primitive_array::<Int64Type>(arr).value(0).to_string(),
DataType::UInt8 => as_primitive_array::<UInt8Type>(arr).value(0).to_string(),
DataType::UInt16 => as_primitive_array::<UInt16Type>(arr).value(0).to_string(),
DataType::UInt32 => as_primitive_array::<UInt32Type>(arr).value(0).to_string(),
DataType::UInt64 => as_primitive_array::<UInt64Type>(arr).value(0).to_string(),
DataType::Utf8 => {
let data = arrow::array::as_string_array(arr);
data.value(0).to_string()
}
// TODO: handle more types
_ => {
unimplemented!("Unimplemented data type: {:?}", data_type);
}
};
Ok(Some(s))
}

Use Case

Related Issue(s)

@wjones127 wjones127 added enhancement New feature or request good first issue Good for newcomers binding/rust Issues for the Rust crate labels Feb 22, 2023
@wjones127
Copy link
Collaborator Author

We should make sure to test this well to avoid issues like those in #1146.

wjones127 added a commit that referenced this issue Mar 6, 2023
# Description
Adds boolean, date, timestamp & binary partition value types

# Related Issue(s)
closes #1170

---------

Signed-off-by: Marijn Valk <[email protected]>
Co-authored-by: Will Jones <[email protected]>
chitralverma pushed a commit to chitralverma/delta-rs that referenced this issue Mar 17, 2023
# Description
Adds boolean, date, timestamp & binary partition value types

# Related Issue(s)
closes delta-io#1170

---------

Signed-off-by: Marijn Valk <[email protected]>
Co-authored-by: Will Jones <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binding/rust Issues for the Rust crate enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant