mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-25 01:10:37 +00:00
chore: upgrade DataFusion family (#7558)
* chore: upgrade DataFusion family Signed-off-by: luofucong <luofc@foxmail.com> * use main proto Signed-off-by: luofucong <luofc@foxmail.com> * fix ci Signed-off-by: luofucong <luofc@foxmail.com> --------- Signed-off-by: luofucong <luofc@foxmail.com>
This commit is contained in:
@@ -1145,10 +1145,11 @@ impl TryFrom<ScalarValue> for Value {
|
||||
ScalarValue::List(array) => {
|
||||
// this is for item type
|
||||
let datatype = ConcreteDataType::try_from(&array.value_type())?;
|
||||
let items = ScalarValue::convert_array_to_scalar_vec(array.as_ref())
|
||||
.context(ConvertArrowArrayToScalarsSnafu)?
|
||||
let scalar_values = ScalarValue::convert_array_to_scalar_vec(array.as_ref())
|
||||
.context(ConvertArrowArrayToScalarsSnafu)?;
|
||||
let items = scalar_values
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.flat_map(|v| v.unwrap_or_else(|| vec![ScalarValue::Null]))
|
||||
.map(|x| x.try_into())
|
||||
.collect::<Result<Vec<Value>>>()?;
|
||||
Value::List(ListValue::new(items, Arc::new(datatype)))
|
||||
@@ -2997,6 +2998,7 @@ pub(crate) mod tests {
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.flatten()
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(
|
||||
vs,
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
// limitations under the License.
|
||||
|
||||
use std::any::Any;
|
||||
use std::borrow::Borrow;
|
||||
use std::sync::Arc;
|
||||
|
||||
use arrow::array::{Array, ArrayBuilder, ArrayIter, ArrayRef, BooleanArray, BooleanBuilder};
|
||||
@@ -69,8 +68,8 @@ impl From<Vec<Option<bool>>> for BooleanVector {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Ptr: Borrow<Option<bool>>> FromIterator<Ptr> for BooleanVector {
|
||||
fn from_iter<I: IntoIterator<Item = Ptr>>(iter: I) -> Self {
|
||||
impl FromIterator<Option<bool>> for BooleanVector {
|
||||
fn from_iter<T: IntoIterator<Item = Option<bool>>>(iter: T) -> Self {
|
||||
BooleanVector {
|
||||
array: BooleanArray::from_iter(iter),
|
||||
}
|
||||
@@ -303,7 +302,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_boolean_vector_from_iter() {
|
||||
let input = vec![Some(false), Some(true), Some(false), Some(true)];
|
||||
let vec = input.iter().collect::<BooleanVector>();
|
||||
let vec = input.iter().cloned().collect::<BooleanVector>();
|
||||
assert_eq!(4, vec.len());
|
||||
for (i, v) in input.into_iter().enumerate() {
|
||||
assert_eq!(v, vec.get_data(i), "Failed at {i}")
|
||||
|
||||
@@ -83,8 +83,6 @@ impl Decimal128Vector {
|
||||
/// For example:
|
||||
/// value = 12345, precision = 3, return error.
|
||||
pub fn with_precision_and_scale(self, precision: u8, scale: i8) -> Result<Self> {
|
||||
// validate if precision is too small
|
||||
self.validate_decimal_precision(precision)?;
|
||||
let array = self
|
||||
.array
|
||||
.with_precision_and_scale(precision, scale)
|
||||
@@ -124,7 +122,7 @@ impl Decimal128Vector {
|
||||
}
|
||||
|
||||
/// Validate decimal precision, if precision is invalid, return error.
|
||||
fn validate_decimal_precision(&self, precision: u8) -> Result<()> {
|
||||
pub fn validate_decimal_precision(&self, precision: u8) -> Result<()> {
|
||||
self.array
|
||||
.validate_decimal_precision(precision)
|
||||
.context(ValueExceedsPrecisionSnafu { precision })
|
||||
@@ -564,7 +562,9 @@ pub mod tests {
|
||||
let decimal_vector = decimal_builder.finish();
|
||||
assert_eq!(decimal_vector.precision(), 38);
|
||||
assert_eq!(decimal_vector.scale(), 10);
|
||||
let result = decimal_vector.with_precision_and_scale(3, 2);
|
||||
let result = decimal_vector
|
||||
.with_precision_and_scale(3, 2)
|
||||
.and_then(|x| x.validate_decimal_precision(3));
|
||||
assert_eq!(
|
||||
"Value exceeds the precision 3 bound",
|
||||
result.unwrap_err().to_string()
|
||||
|
||||
@@ -170,10 +170,11 @@ impl Helper {
|
||||
ScalarValue::List(array) => {
|
||||
let item_type = Arc::new(ConcreteDataType::try_from(&array.value_type())?);
|
||||
let mut builder = ListVectorBuilder::with_type_capacity(item_type.clone(), 1);
|
||||
let values = ScalarValue::convert_array_to_scalar_vec(array.as_ref())
|
||||
.context(ConvertArrowArrayToScalarsSnafu)?
|
||||
let scalar_values = ScalarValue::convert_array_to_scalar_vec(array.as_ref())
|
||||
.context(ConvertArrowArrayToScalarsSnafu)?;
|
||||
let values = scalar_values
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.flat_map(|v| v.unwrap_or_else(|| vec![ScalarValue::Null]))
|
||||
.map(ScalarValue::try_into)
|
||||
.collect::<Result<Vec<Value>>>()?;
|
||||
builder.push(Some(ListValueRef::Ref {
|
||||
|
||||
Reference in New Issue
Block a user