Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into row-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Aug 11, 2022
2 parents 623587d + 4481993 commit 16c0c0e
Show file tree
Hide file tree
Showing 36 changed files with 1,288 additions and 436 deletions.
1 change: 1 addition & 0 deletions arrow-flight/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use std::{
ops::Deref,
};

#[allow(clippy::derive_partial_eq_without_eq)]
mod gen {
include!("arrow.flight.protocol.rs");
}
Expand Down
4 changes: 2 additions & 2 deletions arrow-flight/src/sql/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ where
let record_count = self.do_put_statement_update(token, request).await?;
let result = DoPutUpdateResult { record_count };
let output = futures::stream::iter(vec![Ok(super::super::gen::PutResult {
app_metadata: result.as_any().encode_to_vec(),
app_metadata: result.encode_to_vec(),
})]);
return Ok(Response::new(Box::pin(output)));
}
Expand All @@ -525,7 +525,7 @@ where
.await?;
let result = DoPutUpdateResult { record_count };
let output = futures::stream::iter(vec![Ok(super::super::gen::PutResult {
app_metadata: result.as_any().encode_to_vec(),
app_metadata: result.encode_to_vec(),
})]);
return Ok(Response::new(Box::pin(output)));
}
Expand Down
12 changes: 3 additions & 9 deletions arrow/src/array/array_decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ pub type Decimal128Array = BasicDecimalArray<16>;

pub type Decimal256Array = BasicDecimalArray<32>;

mod private_decimal {
pub trait DecimalArrayPrivate {
fn raw_value_data_ptr(&self) -> *const u8;
}
}

pub struct BasicDecimalArray<const BYTE_WIDTH: usize> {
data: ArrayData,
value_data: RawPtrBox<u8>,
Expand All @@ -90,10 +84,10 @@ pub struct BasicDecimalArray<const BYTE_WIDTH: usize> {

impl<const BYTE_WIDTH: usize> BasicDecimalArray<BYTE_WIDTH> {
pub const VALUE_LENGTH: i32 = BYTE_WIDTH as i32;
pub const DEFAULT_TYPE: DataType = BasicDecimal::<BYTE_WIDTH>::DEFAULT_TYPE;
const DEFAULT_TYPE: DataType = BasicDecimal::<BYTE_WIDTH>::DEFAULT_TYPE;
pub const MAX_PRECISION: usize = BasicDecimal::<BYTE_WIDTH>::MAX_PRECISION;
pub const MAX_SCALE: usize = BasicDecimal::<BYTE_WIDTH>::MAX_SCALE;
pub const TYPE_CONSTRUCTOR: fn(usize, usize) -> DataType =
const TYPE_CONSTRUCTOR: fn(usize, usize) -> DataType =
BasicDecimal::<BYTE_WIDTH>::TYPE_CONSTRUCTOR;

pub fn data(&self) -> &ArrayData {
Expand Down Expand Up @@ -341,7 +335,7 @@ impl Decimal256Array {
pub fn validate_decimal_precision(&self, precision: usize) -> Result<()> {
if precision < self.precision {
for v in self.iter().flatten() {
validate_decimal256_precision(&v.to_string(), precision)?;
validate_decimal256_precision(&v.to_big_int(), precision)?;
}
}
Ok(())
Expand Down
3 changes: 1 addition & 2 deletions arrow/src/array/builder/decimal_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ impl Decimal256Builder {
let value = if self.value_validation {
let raw_bytes = value.raw_value();
let integer = BigInt::from_signed_bytes_le(raw_bytes);
let value_str = integer.to_string();
validate_decimal256_precision(&value_str, self.precision)?;
validate_decimal256_precision(&integer, self.precision)?;
value
} else {
value
Expand Down
29 changes: 17 additions & 12 deletions arrow/src/array/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,18 +396,24 @@ impl ArrayData {
/// panic's if the new DataType is not compatible with the
/// existing type.
///
/// Note: currently only changing a [DataType::Decimal128]s precision
/// and scale are supported
/// Note: currently only changing a [DataType::Decimal128]s or
/// [DataType::Decimal256]s precision and scale are supported
#[inline]
pub(crate) fn with_data_type(mut self, new_data_type: DataType) -> Self {
assert!(
matches!(self.data_type, DataType::Decimal128(_, _)),
"only DecimalType is supported for existing type"
);
assert!(
matches!(new_data_type, DataType::Decimal128(_, _)),
"only DecimalType is supported for new datatype"
);
if matches!(self.data_type, DataType::Decimal128(_, _)) {
assert!(
matches!(new_data_type, DataType::Decimal128(_, _)),
"only 128-bit DecimalType is supported for new datatype"
);
} else if matches!(self.data_type, DataType::Decimal256(_, _)) {
assert!(
matches!(new_data_type, DataType::Decimal256(_, _)),
"only 256-bit DecimalType is supported for new datatype"
);
} else {
panic!("only DecimalType is supported.")
}

self.data_type = new_data_type;
self
}
Expand Down Expand Up @@ -1044,8 +1050,7 @@ impl ArrayData {
let offset = pos * 32;
let raw_bytes = &values[offset..offset + 32];
let integer = BigInt::from_signed_bytes_le(raw_bytes);
let value_str = integer.to_string();
validate_decimal256_precision(&value_str, *p)?;
validate_decimal256_precision(&integer, *p)?;
}
Ok(())
}
Expand Down
Loading

0 comments on commit 16c0c0e

Please sign in to comment.