Skip to content

Commit

Permalink
Add human readable Format for parquet ByteArray (#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb authored Jul 31, 2021
1 parent 9be938e commit b38a4b6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion parquet/src/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,23 @@ impl fmt::Display for Int96 {

/// Rust representation for BYTE_ARRAY and FIXED_LEN_BYTE_ARRAY Parquet physical types.
/// Value is backed by a byte buffer.
#[derive(Clone, Debug)]
#[derive(Clone)]
pub struct ByteArray {
data: Option<ByteBufferPtr>,
}

// Special case Debug that prints out byte arrays that are vaid utf8 as &str's
impl std::fmt::Debug for ByteArray {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut debug_struct = f.debug_struct("ByteArray");
match self.as_utf8() {
Ok(s) => debug_struct.field("data", &s),
Err(_) => debug_struct.field("data", &self.data),
};
debug_struct.finish()
}
}

impl PartialOrd for ByteArray {
fn partial_cmp(&self, other: &ByteArray) -> Option<Ordering> {
if self.data.is_some() && other.data.is_some() {
Expand Down

0 comments on commit b38a4b6

Please sign in to comment.