From bbd02ac2d84a4f13bdd09e0b4ea800f393a70f9c Mon Sep 17 00:00:00 2001 From: sundyli <543950155@qq.com> Date: Fri, 15 Dec 2023 22:05:26 +0800 Subject: [PATCH 1/7] feat(query): add decimal round/truncate function --- src/query/expression/src/type_check.rs | 29 +++ src/query/functions/src/scalars/decimal.rs | 207 +++++++++++++++++++++ src/query/functions/src/scalars/math.rs | 4 + 3 files changed, 240 insertions(+) diff --git a/src/query/expression/src/type_check.rs b/src/query/expression/src/type_check.rs index 1ad545dbddb7..bd4f82733c18 100755 --- a/src/query/expression/src/type_check.rs +++ b/src/query/expression/src/type_check.rs @@ -28,9 +28,12 @@ use crate::function::FunctionSignature; use crate::types::decimal::DecimalSize; use crate::types::decimal::MAX_DECIMAL128_PRECISION; use crate::types::decimal::MAX_DECIMAL256_PRECISION; +use crate::types::ArgType; use crate::types::DataType; use crate::types::DecimalDataType; +use crate::types::Int64Type; use crate::types::Number; +use crate::types::NumberScalar; use crate::AutoCastRules; use crate::ColumnIndex; use crate::ConstantFolder; @@ -124,6 +127,32 @@ pub fn check( } } + // inject the params + if ["round", "truncate"].contains(&name.as_str()) && params.is_empty() { + let mut scale = 0; + let mut new_args = args_expr.clone(); + + if args_expr.len() == 2 { + let scalar_expr = &args_expr[1]; + scale = check_number::<_, i64>( + scalar_expr.span(), + &FunctionContext::default(), + scalar_expr, + fn_registry, + )?; + } else { + new_args.push(Expr::Constant { + span: None, + scalar: Scalar::Number(NumberScalar::Int64(scale)), + data_type: Int64Type::data_type(), + }) + } + scale = scale.clamp(-76, 76); + let add_on_scale = (scale + 76) as usize; + let params = vec![add_on_scale]; + return check_function(*span, name, ¶ms, &args_expr, fn_registry); + } + check_function(*span, name, params, &args_expr, fn_registry) } RawExpr::LambdaFunctionCall { diff --git a/src/query/functions/src/scalars/decimal.rs b/src/query/functions/src/scalars/decimal.rs index 838038cec67a..b137371cd150 100644 --- a/src/query/functions/src/scalars/decimal.rs +++ b/src/query/functions/src/scalars/decimal.rs @@ -1639,3 +1639,210 @@ fn decimal_to_int( Value::Column(result) } } + +// round, truncate +pub fn register_decimal_round_truncate(registry: &mut FunctionRegistry) { + let factory = |is_round: bool, params: &[usize], args_type: &[DataType]| { + if args_type.is_empty() { + return None; + } + + if params.len() != 1 { + return None; + } + + let from_type = args_type[0].remove_nullable(); + if !matches!(from_type, DataType::Decimal(_)) { + return None; + } + + let from_decimal_type = from_type.as_decimal().unwrap(); + + let scale = params[0] as i64 - 76; + + let decimal_size = DecimalSize { + precision: from_decimal_type.precision(), + scale: scale.clamp(0, from_decimal_type.scale() as i64) as u8, + }; + + let dest_decimal_type = DecimalDataType::from_size(decimal_size).ok()?; + let name = if is_round { "round" } else { "truncate" }; + + Some(Function { + signature: FunctionSignature { + name: name.to_owned(), + args_type: vec![from_type.clone(), Int64Type::data_type()], + return_type: DataType::Decimal(dest_decimal_type), + }, + eval: FunctionEval::Scalar { + calc_domain: Box::new(move |_ctx, _d| FunctionDomain::Full), + eval: Box::new(move |args, _ctx| { + decimal_round_truncate( + is_round, + &args[0], + from_type.clone(), + dest_decimal_type, + scale, + ) + }), + }, + }) + }; + + registry.register_function_factory("round", move |params, args_type| { + Some(Arc::new(factory(true, params, args_type)?)) + }); + + registry.register_function_factory("round", move |params, args_type| { + let f = factory(true, params, args_type)?; + Some(Arc::new(f.passthrough_nullable())) + }); + + registry.register_function_factory("truncate", move |params, args_type| { + Some(Arc::new(factory(false, params, args_type)?)) + }); + + registry.register_function_factory("truncate", move |params, args_type| { + let f = factory(false, params, args_type)?; + Some(Arc::new(f.passthrough_nullable())) + }); +} + +macro_rules! decimal_round_positive_macro { + ($T:ty, $values: expr, $source_scale:expr, $target_scale:expr) => {{ + let power_of_ten = <$T>::e(($source_scale - $target_scale) as u32); + let addition = power_of_ten / <$T>::from(2); + + let results: Vec<$T> = $values + .iter() + .map(|input| { + let input = if input < &0 { + input - addition + } else { + input + addition + }; + input / power_of_ten + }) + .collect(); + results + }}; +} + +macro_rules! decimal_round_negative_macro { + ($T:ty, $values: expr, $source_scale:expr, $target_scale:expr) => {{ + let divide_power_of_ten = <$T>::e(($source_scale - $target_scale) as u32); + let addition = divide_power_of_ten / <$T>::from(2); + let multiply_power_of_ten = <$T>::e((-$target_scale) as u32); + + let results: Vec<$T> = $values + .iter() + .map(|input| { + let input = if input < &0 { + input - addition + } else { + input + addition + }; + input / divide_power_of_ten * multiply_power_of_ten + }) + .collect(); + results + }}; +} + +macro_rules! decimal_truncate_positive_macro { + ($T:ty, $values: expr, $source_scale:expr, $target_scale:expr) => {{ + let power_of_ten = <$T>::e(($source_scale - $target_scale) as u32); + let results: Vec<$T> = $values.iter().map(|input| input / power_of_ten).collect(); + results + }}; +} + +macro_rules! decimal_truncate_negative_macro { + ($T:ty, $values: expr, $source_scale:expr, $target_scale:expr) => {{ + let divide_power_of_ten = <$T>::e(($source_scale - $target_scale) as u32); + let multiply_power_of_ten = <$T>::e((-$target_scale) as u32); + + let results: Vec<$T> = $values + .iter() + .map(|input| input / divide_power_of_ten * multiply_power_of_ten) + .collect(); + results + }}; +} + +fn decimal_round_truncate( + is_round: bool, + arg: &ValueRef, + from_type: DataType, + dest_type: DecimalDataType, + target_scale: i64, +) -> Value { + let from_decimal_type = from_type.as_decimal().unwrap(); + let source_scale = from_decimal_type.scale() as i64; + + if source_scale < target_scale { + return arg.clone().to_owned(); + } + + let mut is_scalar = false; + let column = match arg { + ValueRef::Column(column) => column.clone(), + ValueRef::Scalar(s) => { + is_scalar = true; + let builder = ColumnBuilder::repeat(s, 1, &from_type); + builder.build() + } + }; + + let positive = target_scale >= 0; + + let result = match from_decimal_type { + DecimalDataType::Decimal128(_) => { + let (buffer, _) = i128::try_downcast_column(&column).unwrap(); + + let result = match (positive, is_round) { + (true, true) => { + decimal_round_positive_macro! {i128, buffer, source_scale, target_scale} + } + (false, true) => { + decimal_round_negative_macro! {i128, buffer, source_scale, target_scale} + } + (true, false) => { + decimal_truncate_positive_macro! {i128, buffer, source_scale, target_scale} + } + (false, false) => { + decimal_truncate_negative_macro! {i128, buffer, source_scale, target_scale} + } + }; + + i128::to_column(result, dest_type.size()) + } + + DecimalDataType::Decimal256(_) => { + let (buffer, _) = i256::try_downcast_column(&column).unwrap(); + let result = match (positive, is_round) { + (true, true) => { + decimal_round_positive_macro! {i256, buffer, source_scale, target_scale} + } + (false, true) => { + decimal_round_negative_macro! {i256, buffer, source_scale, target_scale} + } + (true, false) => { + decimal_truncate_positive_macro! {i256, buffer, source_scale, target_scale} + } + (false, false) => { + decimal_truncate_negative_macro! {i256, buffer, source_scale, target_scale} + } + }; + i256::to_column(result, dest_type.size()) + } + }; + + let result = Column::Decimal(result); + if is_scalar { + let scalar = result.index(0).unwrap(); + Value::Scalar(scalar.to_owned()) + } else { + Value::Column(result) + } +} diff --git a/src/query/functions/src/scalars/math.rs b/src/query/functions/src/scalars/math.rs index 052506d9f488..4ac7c563d744 100644 --- a/src/query/functions/src/scalars/math.rs +++ b/src/query/functions/src/scalars/math.rs @@ -35,6 +35,8 @@ use num_traits::Float; use num_traits::Pow; use ordered_float::OrderedFloat; +use crate::scalars::decimal::register_decimal_round_truncate; + pub fn register(registry: &mut FunctionRegistry) { registry.register_1_arg::, NumberType, _, _>( "sin", @@ -244,6 +246,8 @@ pub fn register(registry: &mut FunctionRegistry) { |lhs, rhs, _| OrderedFloat(lhs.0.pow(rhs.0)), ); + register_decimal_round_truncate(registry); + for ty in ALL_NUMERICS_TYPES { with_number_mapped_type!(|NUM_TYPE| match ty { NumberDataType::NUM_TYPE => { From 6ea4ba3e4b96cc22fbd7f8424f3414f9a9e2227a Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Sun, 17 Dec 2023 00:04:09 +0800 Subject: [PATCH 2/7] chore(query): add tests --- src/query/functions/src/scalars/decimal.rs | 255 ++++++++++++------ src/query/functions/src/scalars/math.rs | 6 +- .../it/scalars/testdata/function_list.txt | 212 ++++++++------- .../tests/it/scalars/testdata/math.txt | 90 +++---- src/tests/sqlsmith/src/sql_gen/func.rs | 4 +- .../02_function/02_0014_function_maths.test | 22 ++ 6 files changed, 343 insertions(+), 246 deletions(-) diff --git a/src/query/functions/src/scalars/decimal.rs b/src/query/functions/src/scalars/decimal.rs index b137371cd150..c933cbf98447 100644 --- a/src/query/functions/src/scalars/decimal.rs +++ b/src/query/functions/src/scalars/decimal.rs @@ -1641,16 +1641,12 @@ fn decimal_to_int( } // round, truncate -pub fn register_decimal_round_truncate(registry: &mut FunctionRegistry) { - let factory = |is_round: bool, params: &[usize], args_type: &[DataType]| { +pub fn register_decimal_math(registry: &mut FunctionRegistry) { + let factory = |params: &[usize], args_type: &[DataType], round_mode: RoundMode| { if args_type.is_empty() { return None; } - if params.len() != 1 { - return None; - } - let from_type = args_type[0].remove_nullable(); if !matches!(from_type, DataType::Decimal(_)) { return None; @@ -1658,7 +1654,11 @@ pub fn register_decimal_round_truncate(registry: &mut FunctionRegistry) { let from_decimal_type = from_type.as_decimal().unwrap(); - let scale = params[0] as i64 - 76; + let scale = if params.is_empty() { + 0 + } else { + params[0] as i64 - 76 + }; let decimal_size = DecimalSize { precision: from_decimal_type.precision(), @@ -1666,23 +1666,23 @@ pub fn register_decimal_round_truncate(registry: &mut FunctionRegistry) { }; let dest_decimal_type = DecimalDataType::from_size(decimal_size).ok()?; - let name = if is_round { "round" } else { "truncate" }; + let name = format!("{:?}", round_mode).to_lowercase(); Some(Function { signature: FunctionSignature { - name: name.to_owned(), - args_type: vec![from_type.clone(), Int64Type::data_type()], + name, + args_type: args_type.to_owned(), return_type: DataType::Decimal(dest_decimal_type), }, eval: FunctionEval::Scalar { calc_domain: Box::new(move |_ctx, _d| FunctionDomain::Full), eval: Box::new(move |args, _ctx| { decimal_round_truncate( - is_round, &args[0], from_type.clone(), dest_decimal_type, scale, + round_mode, ) }), }, @@ -1690,92 +1690,170 @@ pub fn register_decimal_round_truncate(registry: &mut FunctionRegistry) { }; registry.register_function_factory("round", move |params, args_type| { - Some(Arc::new(factory(true, params, args_type)?)) + Some(Arc::new(factory(params, args_type, RoundMode::Round)?)) }); registry.register_function_factory("round", move |params, args_type| { - let f = factory(true, params, args_type)?; + let f = factory(params, args_type, RoundMode::Round)?; Some(Arc::new(f.passthrough_nullable())) }); registry.register_function_factory("truncate", move |params, args_type| { - Some(Arc::new(factory(false, params, args_type)?)) + Some(Arc::new(factory(params, args_type, RoundMode::Truncate)?)) }); registry.register_function_factory("truncate", move |params, args_type| { - let f = factory(false, params, args_type)?; + let f = factory(params, args_type, RoundMode::Truncate)?; + Some(Arc::new(f.passthrough_nullable())) + }); + + registry.register_function_factory("ceil", move |params, args_type| { + Some(Arc::new(factory(params, args_type, RoundMode::Ceil)?)) + }); + + registry.register_function_factory("ceil", move |params, args_type| { + let f = factory(params, args_type, RoundMode::Ceil)?; + Some(Arc::new(f.passthrough_nullable())) + }); + + registry.register_function_factory("floor", move |params, args_type| { + Some(Arc::new(factory(params, args_type, RoundMode::Floor)?)) + }); + + registry.register_function_factory("floor", move |params, args_type| { + let f = factory(params, args_type, RoundMode::Floor)?; Some(Arc::new(f.passthrough_nullable())) }); } -macro_rules! decimal_round_positive_macro { - ($T:ty, $values: expr, $source_scale:expr, $target_scale:expr) => {{ - let power_of_ten = <$T>::e(($source_scale - $target_scale) as u32); - let addition = power_of_ten / <$T>::from(2); +#[derive(Copy, Clone, Debug)] +enum RoundMode { + Round, + Truncate, + Floor, + Ceil, +} - let results: Vec<$T> = $values - .iter() - .map(|input| { - let input = if input < &0 { - input - addition - } else { - input + addition - }; - input / power_of_ten - }) - .collect(); - results - }}; +fn decimal_round_positive(values: &[T], source_scale: i64, target_scale: i64) -> Vec +where T: Decimal + From + DivAssign + Div + Add + Sub { + let power_of_ten = T::e((source_scale - target_scale) as u32); + let addition = power_of_ten / T::from(2); + + values + .iter() + .map(|input| { + let input = if input < &T::zero() { + *input - addition + } else { + *input + addition + }; + input / power_of_ten + }) + .collect() } -macro_rules! decimal_round_negative_macro { - ($T:ty, $values: expr, $source_scale:expr, $target_scale:expr) => {{ - let divide_power_of_ten = <$T>::e(($source_scale - $target_scale) as u32); - let addition = divide_power_of_ten / <$T>::from(2); - let multiply_power_of_ten = <$T>::e((-$target_scale) as u32); +fn decimal_round_negative(values: &[T], source_scale: i64, target_scale: i64) -> Vec +where T: Decimal + + From + + DivAssign + + Div + + Add + + Sub + + Mul { + let divide_power_of_ten = T::e((source_scale - target_scale) as u32); + let addition = divide_power_of_ten / T::from(2); + let multiply_power_of_ten = T::e((-target_scale) as u32); + + values + .iter() + .map(|input| { + let input = if input < &T::zero() { + *input - addition + } else { + *input + addition + }; + input / divide_power_of_ten * multiply_power_of_ten + }) + .collect() +} - let results: Vec<$T> = $values - .iter() - .map(|input| { - let input = if input < &0 { - input - addition - } else { - input + addition - }; - input / divide_power_of_ten * multiply_power_of_ten - }) - .collect(); - results - }}; +// if round mode is ceil, truncate should add one value +fn decimal_truncate_positive(values: &[T], source_scale: i64, target_scale: i64) -> Vec +where T: Decimal + From + DivAssign + Div + Add + Sub { + let power_of_ten = T::e((source_scale - target_scale) as u32); + + values.iter().map(|input| *input / power_of_ten).collect() } -macro_rules! decimal_truncate_positive_macro { - ($T:ty, $values: expr, $source_scale:expr, $target_scale:expr) => {{ - let power_of_ten = <$T>::e(($source_scale - $target_scale) as u32); - let results: Vec<$T> = $values.iter().map(|input| input / power_of_ten).collect(); - results - }}; +fn decimal_truncate_negative(values: &[T], source_scale: i64, target_scale: i64) -> Vec +where T: Decimal + + From + + DivAssign + + Div + + Add + + Sub + + Mul { + let divide_power_of_ten = T::e((source_scale - target_scale) as u32); + let multiply_power_of_ten = T::e((-target_scale) as u32); + + values + .iter() + .map(|input| *input / divide_power_of_ten * multiply_power_of_ten) + .collect() } -macro_rules! decimal_truncate_negative_macro { - ($T:ty, $values: expr, $source_scale:expr, $target_scale:expr) => {{ - let divide_power_of_ten = <$T>::e(($source_scale - $target_scale) as u32); - let multiply_power_of_ten = <$T>::e((-$target_scale) as u32); +fn decimal_floor(values: &[T], source_scale: i64) -> Vec +where T: Decimal + + From + + DivAssign + + Div + + Add + + Sub + + Mul { + let power_of_ten = T::e(source_scale as u32); + + values + .iter() + .map(|input| { + if input < &T::zero() { + // below 0 we ceil the number (e.g. -10.5 -> -11) + ((*input + T::one()) / power_of_ten) - T::one() + } else { + *input / power_of_ten + } + }) + .collect() +} - let results: Vec<$T> = $values - .iter() - .map(|input| input / divide_power_of_ten * multiply_power_of_ten) - .collect(); - results - }}; +fn decimal_ceil(values: &[T], source_scale: i64) -> Vec +where T: Decimal + + From + + DivAssign + + Div + + Add + + Sub + + Mul { + let power_of_ten = T::e(source_scale as u32); + + values + .iter() + .map(|input| { + match input.cmp(&T::zero()) { + // below 0 we floor the number (e.g. -10.5 -> -10) + std::cmp::Ordering::Less => *input / power_of_ten, + std::cmp::Ordering::Equal => T::zero(), + std::cmp::Ordering::Greater => ((*input - T::one()) / power_of_ten) + T::one(), + } + }) + .collect() } fn decimal_round_truncate( - is_round: bool, arg: &ValueRef, from_type: DataType, dest_type: DecimalDataType, target_scale: i64, + mode: RoundMode, ) -> Value { let from_decimal_type = from_type.as_decimal().unwrap(); let source_scale = from_decimal_type.scale() as i64; @@ -1794,45 +1872,48 @@ fn decimal_round_truncate( } }; - let positive = target_scale >= 0; + let none_negative = target_scale >= 0; let result = match from_decimal_type { DecimalDataType::Decimal128(_) => { let (buffer, _) = i128::try_downcast_column(&column).unwrap(); - let result = match (positive, is_round) { - (true, true) => { - decimal_round_positive_macro! {i128, buffer, source_scale, target_scale} + let result = match (none_negative, mode) { + (true, RoundMode::Round) => { + decimal_round_positive::<_>(&buffer, source_scale, target_scale) } - (false, true) => { - decimal_round_negative_macro! {i128, buffer, source_scale, target_scale} + (true, RoundMode::Truncate) => { + decimal_truncate_positive::<_>(&buffer, source_scale, target_scale) } - (true, false) => { - decimal_truncate_positive_macro! {i128, buffer, source_scale, target_scale} + (false, RoundMode::Round) => { + decimal_round_negative::<_>(&buffer, source_scale, target_scale) } - (false, false) => { - decimal_truncate_negative_macro! {i128, buffer, source_scale, target_scale} + (false, RoundMode::Truncate) => { + decimal_truncate_negative::<_>(&buffer, source_scale, target_scale) } + (_, RoundMode::Floor) => decimal_floor::<_>(&buffer, source_scale), + (_, RoundMode::Ceil) => decimal_ceil::<_>(&buffer, source_scale), }; - i128::to_column(result, dest_type.size()) } DecimalDataType::Decimal256(_) => { let (buffer, _) = i256::try_downcast_column(&column).unwrap(); - let result = match (positive, is_round) { - (true, true) => { - decimal_round_positive_macro! {i256, buffer, source_scale, target_scale} + let result = match (none_negative, mode) { + (true, RoundMode::Round) => { + decimal_round_positive::<_>(&buffer, source_scale, target_scale) } - (false, true) => { - decimal_round_negative_macro! {i256, buffer, source_scale, target_scale} + (true, RoundMode::Truncate) => { + decimal_truncate_positive::<_>(&buffer, source_scale, target_scale) } - (true, false) => { - decimal_truncate_positive_macro! {i256, buffer, source_scale, target_scale} + (false, RoundMode::Round) => { + decimal_round_negative::<_>(&buffer, source_scale, target_scale) } - (false, false) => { - decimal_truncate_negative_macro! {i256, buffer, source_scale, target_scale} + (false, RoundMode::Truncate) => { + decimal_truncate_negative::<_>(&buffer, source_scale, target_scale) } + (_, RoundMode::Floor) => decimal_floor::<_>(&buffer, source_scale), + (_, RoundMode::Ceil) => decimal_ceil::<_>(&buffer, source_scale), }; i256::to_column(result, dest_type.size()) } diff --git a/src/query/functions/src/scalars/math.rs b/src/query/functions/src/scalars/math.rs index 4ac7c563d744..5691a50e7656 100644 --- a/src/query/functions/src/scalars/math.rs +++ b/src/query/functions/src/scalars/math.rs @@ -35,9 +35,11 @@ use num_traits::Float; use num_traits::Pow; use ordered_float::OrderedFloat; -use crate::scalars::decimal::register_decimal_round_truncate; +use crate::scalars::decimal::register_decimal_math; pub fn register(registry: &mut FunctionRegistry) { + register_decimal_math(registry); + registry.register_1_arg::, NumberType, _, _>( "sin", |_, _| { @@ -246,8 +248,6 @@ pub fn register(registry: &mut FunctionRegistry) { |lhs, rhs, _| OrderedFloat(lhs.0.pow(rhs.0)), ); - register_decimal_round_truncate(registry); - for ty in ALL_NUMERICS_TYPES { with_number_mapped_type!(|NUM_TYPE| match ty { NumberDataType::NUM_TYPE => { diff --git a/src/query/functions/tests/it/scalars/testdata/function_list.txt b/src/query/functions/tests/it/scalars/testdata/function_list.txt index ba780142d03a..b7353f14cf2e 100644 --- a/src/query/functions/tests/it/scalars/testdata/function_list.txt +++ b/src/query/functions/tests/it/scalars/testdata/function_list.txt @@ -758,26 +758,28 @@ Functions overloads: 17 cbrt(Float32 NULL) :: Float64 NULL 18 cbrt(Float64) :: Float64 19 cbrt(Float64 NULL) :: Float64 NULL -0 ceil(UInt8) :: UInt8 -1 ceil(UInt8 NULL) :: UInt8 NULL -2 ceil(UInt16) :: UInt16 -3 ceil(UInt16 NULL) :: UInt16 NULL -4 ceil(UInt32) :: UInt32 -5 ceil(UInt32 NULL) :: UInt32 NULL -6 ceil(UInt64) :: UInt64 -7 ceil(UInt64 NULL) :: UInt64 NULL -8 ceil(Int8) :: Int8 -9 ceil(Int8 NULL) :: Int8 NULL -10 ceil(Int16) :: Int16 -11 ceil(Int16 NULL) :: Int16 NULL -12 ceil(Int32) :: Int32 -13 ceil(Int32 NULL) :: Int32 NULL -14 ceil(Int64) :: Int64 -15 ceil(Int64 NULL) :: Int64 NULL -16 ceil(Float32) :: Float64 -17 ceil(Float32 NULL) :: Float64 NULL -18 ceil(Float64) :: Float64 -19 ceil(Float64 NULL) :: Float64 NULL +0 ceil FACTORY +1 ceil FACTORY +2 ceil(UInt8) :: UInt8 +3 ceil(UInt8 NULL) :: UInt8 NULL +4 ceil(UInt16) :: UInt16 +5 ceil(UInt16 NULL) :: UInt16 NULL +6 ceil(UInt32) :: UInt32 +7 ceil(UInt32 NULL) :: UInt32 NULL +8 ceil(UInt64) :: UInt64 +9 ceil(UInt64 NULL) :: UInt64 NULL +10 ceil(Int8) :: Int8 +11 ceil(Int8 NULL) :: Int8 NULL +12 ceil(Int16) :: Int16 +13 ceil(Int16 NULL) :: Int16 NULL +14 ceil(Int32) :: Int32 +15 ceil(Int32 NULL) :: Int32 NULL +16 ceil(Int64) :: Int64 +17 ceil(Int64 NULL) :: Int64 NULL +18 ceil(Float32) :: Float64 +19 ceil(Float32 NULL) :: Float64 NULL +20 ceil(Float64) :: Float64 +21 ceil(Float64 NULL) :: Float64 NULL 0 char FACTORY 1 char FACTORY 0 char_length(String) :: UInt64 @@ -1643,8 +1645,10 @@ Functions overloads: 14 factorial(Int64) :: Int64 15 factorial(Int64 NULL) :: Int64 NULL 0 flatten FACTORY -0 floor(Float64) :: Float64 -1 floor(Float64 NULL) :: Float64 NULL +0 floor FACTORY +1 floor FACTORY +2 floor(Float64) :: Float64 +3 floor(Float64 NULL) :: Float64 NULL 0 from_base64(String) :: String 1 from_base64(String NULL) :: String NULL 0 gen_random_uuid() :: String @@ -3009,46 +3013,48 @@ Functions overloads: 1 reverse(String NULL) :: String NULL 0 right(String, UInt64) :: String 1 right(String NULL, UInt64 NULL) :: String NULL -0 round(UInt8) :: Float64 -1 round(UInt8 NULL) :: Float64 NULL -2 round(UInt8, Int64) :: Float64 -3 round(UInt8 NULL, Int64 NULL) :: Float64 NULL -4 round(UInt16) :: Float64 -5 round(UInt16 NULL) :: Float64 NULL -6 round(UInt16, Int64) :: Float64 -7 round(UInt16 NULL, Int64 NULL) :: Float64 NULL -8 round(UInt32) :: Float64 -9 round(UInt32 NULL) :: Float64 NULL -10 round(UInt32, Int64) :: Float64 -11 round(UInt32 NULL, Int64 NULL) :: Float64 NULL -12 round(UInt64) :: Float64 -13 round(UInt64 NULL) :: Float64 NULL -14 round(UInt64, Int64) :: Float64 -15 round(UInt64 NULL, Int64 NULL) :: Float64 NULL -16 round(Int8) :: Float64 -17 round(Int8 NULL) :: Float64 NULL -18 round(Int8, Int64) :: Float64 -19 round(Int8 NULL, Int64 NULL) :: Float64 NULL -20 round(Int16) :: Float64 -21 round(Int16 NULL) :: Float64 NULL -22 round(Int16, Int64) :: Float64 -23 round(Int16 NULL, Int64 NULL) :: Float64 NULL -24 round(Int32) :: Float64 -25 round(Int32 NULL) :: Float64 NULL -26 round(Int32, Int64) :: Float64 -27 round(Int32 NULL, Int64 NULL) :: Float64 NULL -28 round(Int64) :: Float64 -29 round(Int64 NULL) :: Float64 NULL -30 round(Int64, Int64) :: Float64 -31 round(Int64 NULL, Int64 NULL) :: Float64 NULL -32 round(Float32) :: Float64 -33 round(Float32 NULL) :: Float64 NULL -34 round(Float32, Int64) :: Float64 -35 round(Float32 NULL, Int64 NULL) :: Float64 NULL -36 round(Float64) :: Float64 -37 round(Float64 NULL) :: Float64 NULL -38 round(Float64, Int64) :: Float64 -39 round(Float64 NULL, Int64 NULL) :: Float64 NULL +0 round FACTORY +1 round FACTORY +2 round(UInt8) :: Float64 +3 round(UInt8 NULL) :: Float64 NULL +4 round(UInt8, Int64) :: Float64 +5 round(UInt8 NULL, Int64 NULL) :: Float64 NULL +6 round(UInt16) :: Float64 +7 round(UInt16 NULL) :: Float64 NULL +8 round(UInt16, Int64) :: Float64 +9 round(UInt16 NULL, Int64 NULL) :: Float64 NULL +10 round(UInt32) :: Float64 +11 round(UInt32 NULL) :: Float64 NULL +12 round(UInt32, Int64) :: Float64 +13 round(UInt32 NULL, Int64 NULL) :: Float64 NULL +14 round(UInt64) :: Float64 +15 round(UInt64 NULL) :: Float64 NULL +16 round(UInt64, Int64) :: Float64 +17 round(UInt64 NULL, Int64 NULL) :: Float64 NULL +18 round(Int8) :: Float64 +19 round(Int8 NULL) :: Float64 NULL +20 round(Int8, Int64) :: Float64 +21 round(Int8 NULL, Int64 NULL) :: Float64 NULL +22 round(Int16) :: Float64 +23 round(Int16 NULL) :: Float64 NULL +24 round(Int16, Int64) :: Float64 +25 round(Int16 NULL, Int64 NULL) :: Float64 NULL +26 round(Int32) :: Float64 +27 round(Int32 NULL) :: Float64 NULL +28 round(Int32, Int64) :: Float64 +29 round(Int32 NULL, Int64 NULL) :: Float64 NULL +30 round(Int64) :: Float64 +31 round(Int64 NULL) :: Float64 NULL +32 round(Int64, Int64) :: Float64 +33 round(Int64 NULL, Int64 NULL) :: Float64 NULL +34 round(Float32) :: Float64 +35 round(Float32 NULL) :: Float64 NULL +36 round(Float32, Int64) :: Float64 +37 round(Float32 NULL, Int64 NULL) :: Float64 NULL +38 round(Float64) :: Float64 +39 round(Float64 NULL) :: Float64 NULL +40 round(Float64, Int64) :: Float64 +41 round(Float64 NULL, Int64 NULL) :: Float64 NULL 0 rpad(String, UInt64, String) :: String 1 rpad(String NULL, UInt64 NULL, String NULL) :: String NULL 0 rtrim(String) :: String @@ -3647,46 +3653,48 @@ Functions overloads: 1 trim_leading(String NULL, String NULL) :: String NULL 0 trim_trailing(String, String) :: String 1 trim_trailing(String NULL, String NULL) :: String NULL -0 truncate(UInt8) :: Float64 -1 truncate(UInt8 NULL) :: Float64 NULL -2 truncate(UInt8, Int64) :: Float64 -3 truncate(UInt8 NULL, Int64 NULL) :: Float64 NULL -4 truncate(UInt16) :: Float64 -5 truncate(UInt16 NULL) :: Float64 NULL -6 truncate(UInt16, Int64) :: Float64 -7 truncate(UInt16 NULL, Int64 NULL) :: Float64 NULL -8 truncate(UInt32) :: Float64 -9 truncate(UInt32 NULL) :: Float64 NULL -10 truncate(UInt32, Int64) :: Float64 -11 truncate(UInt32 NULL, Int64 NULL) :: Float64 NULL -12 truncate(UInt64) :: Float64 -13 truncate(UInt64 NULL) :: Float64 NULL -14 truncate(UInt64, Int64) :: Float64 -15 truncate(UInt64 NULL, Int64 NULL) :: Float64 NULL -16 truncate(Int8) :: Float64 -17 truncate(Int8 NULL) :: Float64 NULL -18 truncate(Int8, Int64) :: Float64 -19 truncate(Int8 NULL, Int64 NULL) :: Float64 NULL -20 truncate(Int16) :: Float64 -21 truncate(Int16 NULL) :: Float64 NULL -22 truncate(Int16, Int64) :: Float64 -23 truncate(Int16 NULL, Int64 NULL) :: Float64 NULL -24 truncate(Int32) :: Float64 -25 truncate(Int32 NULL) :: Float64 NULL -26 truncate(Int32, Int64) :: Float64 -27 truncate(Int32 NULL, Int64 NULL) :: Float64 NULL -28 truncate(Int64) :: Float64 -29 truncate(Int64 NULL) :: Float64 NULL -30 truncate(Int64, Int64) :: Float64 -31 truncate(Int64 NULL, Int64 NULL) :: Float64 NULL -32 truncate(Float32) :: Float64 -33 truncate(Float32 NULL) :: Float64 NULL -34 truncate(Float32, Int64) :: Float64 -35 truncate(Float32 NULL, Int64 NULL) :: Float64 NULL -36 truncate(Float64) :: Float64 -37 truncate(Float64 NULL) :: Float64 NULL -38 truncate(Float64, Int64) :: Float64 -39 truncate(Float64 NULL, Int64 NULL) :: Float64 NULL +0 truncate FACTORY +1 truncate FACTORY +2 truncate(UInt8) :: Float64 +3 truncate(UInt8 NULL) :: Float64 NULL +4 truncate(UInt8, Int64) :: Float64 +5 truncate(UInt8 NULL, Int64 NULL) :: Float64 NULL +6 truncate(UInt16) :: Float64 +7 truncate(UInt16 NULL) :: Float64 NULL +8 truncate(UInt16, Int64) :: Float64 +9 truncate(UInt16 NULL, Int64 NULL) :: Float64 NULL +10 truncate(UInt32) :: Float64 +11 truncate(UInt32 NULL) :: Float64 NULL +12 truncate(UInt32, Int64) :: Float64 +13 truncate(UInt32 NULL, Int64 NULL) :: Float64 NULL +14 truncate(UInt64) :: Float64 +15 truncate(UInt64 NULL) :: Float64 NULL +16 truncate(UInt64, Int64) :: Float64 +17 truncate(UInt64 NULL, Int64 NULL) :: Float64 NULL +18 truncate(Int8) :: Float64 +19 truncate(Int8 NULL) :: Float64 NULL +20 truncate(Int8, Int64) :: Float64 +21 truncate(Int8 NULL, Int64 NULL) :: Float64 NULL +22 truncate(Int16) :: Float64 +23 truncate(Int16 NULL) :: Float64 NULL +24 truncate(Int16, Int64) :: Float64 +25 truncate(Int16 NULL, Int64 NULL) :: Float64 NULL +26 truncate(Int32) :: Float64 +27 truncate(Int32 NULL) :: Float64 NULL +28 truncate(Int32, Int64) :: Float64 +29 truncate(Int32 NULL, Int64 NULL) :: Float64 NULL +30 truncate(Int64) :: Float64 +31 truncate(Int64 NULL) :: Float64 NULL +32 truncate(Int64, Int64) :: Float64 +33 truncate(Int64 NULL, Int64 NULL) :: Float64 NULL +34 truncate(Float32) :: Float64 +35 truncate(Float32 NULL) :: Float64 NULL +36 truncate(Float32, Int64) :: Float64 +37 truncate(Float32 NULL, Int64 NULL) :: Float64 NULL +38 truncate(Float64) :: Float64 +39 truncate(Float64 NULL) :: Float64 NULL +40 truncate(Float64, Int64) :: Float64 +41 truncate(Float64 NULL, Int64 NULL) :: Float64 NULL 0 try_inet_aton(String) :: UInt32 NULL 1 try_inet_aton(String NULL) :: UInt32 NULL 0 try_inet_ntoa(Int64) :: String NULL diff --git a/src/query/functions/tests/it/scalars/testdata/math.txt b/src/query/functions/tests/it/scalars/testdata/math.txt index 4f3f372b222c..d959a713f93c 100644 --- a/src/query/functions/tests/it/scalars/testdata/math.txt +++ b/src/query/functions/tests/it/scalars/testdata/math.txt @@ -202,9 +202,9 @@ output : 5 ast : ceil(5.6) raw expr : ceil(5.6) -checked expr : ceil(to_float32(5.6_d128(2,1))) -optimized expr : 6_f64 -output type : Float64 +checked expr : ceil(5.6_d128(2,1)) +optimized expr : 6_d128(2,0) +output type : Decimal(2, 0) output domain : {6..=6} output : 6 @@ -281,47 +281,47 @@ evaluation (internal): ast : round(-1.23) raw expr : round(minus(1.23)) -checked expr : round(to_float32(minus(1.23_d128(3,2)))) -optimized expr : -1_f64 -output type : Float64 +checked expr : round(76)(minus(1.23_d128(3,2))) +optimized expr : -1_d128(3,0) +output type : Decimal(3, 0) output domain : {-1..=-1} output : -1 ast : round(1.298, 1) raw expr : round(1.298, 1) -checked expr : round(to_float32(1.298_d128(4,3)), to_int64(1_u8)) -optimized expr : 1.3_f64 -output type : Float64 +checked expr : round(77)(1.298_d128(4,3), 1_u8) +optimized expr : 1.3_d128(4,1) +output type : Decimal(4, 1) output domain : {1.3..=1.3} output : 1.3 ast : round(1.298, 0) raw expr : round(1.298, 0) -checked expr : round(to_float32(1.298_d128(4,3)), to_int64(0_u8)) -optimized expr : 1_f64 -output type : Float64 +checked expr : round(76)(1.298_d128(4,3), 0_u8) +optimized expr : 1_d128(4,0) +output type : Decimal(4, 0) output domain : {1..=1} output : 1 ast : round(23.298, -1) raw expr : round(23.298, minus(1)) -checked expr : round(to_float32(23.298_d128(5,3)), to_int64(minus(1_u8))) -optimized expr : 20_f64 -output type : Float64 +checked expr : round(75)(23.298_d128(5,3), minus(1_u8)) +optimized expr : 20_d128(5,0) +output type : Decimal(5, 0) output domain : {20..=20} output : 20 ast : round(0.12345678901234567890123456789012345, 35) raw expr : round(0.12345678901234567890123456789012345, 35) -checked expr : round(to_float32(0.12345678901234567890123456789012345_d128(35,35)), to_int64(35_u8)) -optimized expr : 0.1234567835_f64 -output type : Float64 -output domain : {0.1234567835..=0.1234567835} -output : 0.1234567835 +checked expr : round(111)(0.12345678901234567890123456789012345_d128(35,35), 35_u8) +optimized expr : 0.12345678901234567890123456789012345_d128(35,35) +output type : Decimal(35, 35) +output domain : {0.12345678901234567890123456789012345..=0.12345678901234567890123456789012345} +output : 0.12345678901234567890123456789012345 ast : round(a) @@ -410,27 +410,27 @@ evaluation (internal): ast : truncate(1.223, 1) raw expr : truncate(1.223, 1) -checked expr : truncate(to_float32(1.223_d128(4,3)), to_int64(1_u8)) -optimized expr : 1.2_f64 -output type : Float64 +checked expr : truncate(77)(1.223_d128(4,3), 1_u8) +optimized expr : 1.2_d128(4,1) +output type : Decimal(4, 1) output domain : {1.2..=1.2} output : 1.2 ast : truncate(1.999) raw expr : truncate(1.999) -checked expr : truncate(to_float32(1.999_d128(4,3))) -optimized expr : 1_f64 -output type : Float64 +checked expr : truncate(76)(1.999_d128(4,3)) +optimized expr : 1_d128(4,0) +output type : Decimal(4, 0) output domain : {1..=1} output : 1 ast : truncate(1.999, 1) raw expr : truncate(1.999, 1) -checked expr : truncate(to_float32(1.999_d128(4,3)), to_int64(1_u8)) -optimized expr : 1.9_f64 -output type : Float64 +checked expr : truncate(77)(1.999_d128(4,3), 1_u8) +optimized expr : 1.9_d128(4,1) +output type : Decimal(4, 1) output domain : {1.9..=1.9} output : 1.9 @@ -446,9 +446,9 @@ output : 100 ast : truncate(10.28*100, 0) raw expr : truncate(multiply(10.28, 100), 0) -checked expr : truncate(to_float32(multiply(to_decimal(7, 2)(10.28_d128(4,2)), to_decimal(7, 0)(100_u8))), to_int64(0_u8)) -optimized expr : 1028_f64 -output type : Float64 +checked expr : truncate(76)(multiply(to_decimal(7, 2)(10.28_d128(4,2)), to_decimal(7, 0)(100_u8)), 0_u8) +optimized expr : 1028_d128(7,0) +output type : Decimal(7, 0) output domain : {1028..=1028} output : 1028 @@ -521,26 +521,12 @@ output domain : {0.6931471805..=0.6931471805} output : 0.6931471805 -ast : round(2, a) -raw expr : round(2, a::Int64) -checked expr : round(2_u8, a) -evaluation: -+--------+--------------+--------------+ -| | a | Output | -+--------+--------------+--------------+ -| Type | Int64 | Float64 | -| Domain | {10..=65536} | {-inf..=NaN} | -| Row 0 | 22 | 2 | -| Row 1 | 65536 | 2 | -| Row 2 | 10 | 2 | -+--------+--------------+--------------+ -evaluation (internal): -+--------+------------------------+ -| Column | Data | -+--------+------------------------+ -| a | Int64([22, 65536, 10]) | -| Output | Float64([2, 2, 2]) | -+--------+------------------------+ +error: + --> SQL:1:10 + | +1 | round(2, a) + | ^ Need constant number. + ast : factorial(5) diff --git a/src/tests/sqlsmith/src/sql_gen/func.rs b/src/tests/sqlsmith/src/sql_gen/func.rs index aa8d4ee3cd15..52fb8cd96de6 100644 --- a/src/tests/sqlsmith/src/sql_gen/func.rs +++ b/src/tests/sqlsmith/src/sql_gen/func.rs @@ -155,8 +155,8 @@ impl<'a, R: Rng> SqlGenerator<'a, R> { 0 => "and_filters".to_string(), 1 => "regexp_like".to_string(), 2 => { - let comp_func = ["eq", "gt", "gte", "lt", "lte", "ne", "noteq"]; - comp_func[self.rng.gen_range(0..=6)].to_string() + let comp_func = ["eq", "gt", "gte", "lt", "lte", "noteq"]; + comp_func[self.rng.gen_range(0..=5)].to_string() } 3 => "ignore".to_string(), diff --git a/tests/sqllogictests/suites/query/02_function/02_0014_function_maths.test b/tests/sqllogictests/suites/query/02_function/02_0014_function_maths.test index d2780f51f7fd..c8c5c88bbc3a 100644 --- a/tests/sqllogictests/suites/query/02_function/02_0014_function_maths.test +++ b/tests/sqllogictests/suites/query/02_function/02_0014_function_maths.test @@ -342,3 +342,25 @@ query I select abs(-9223372036854775808) ---- 9223372036854775808 + +query IIIIII +SELECT floor(123.45), floor(-123.45), floor(0.0), floor(123456789.123), floor(-123456789.123), floor(123456.7891) +---- +123 -124 0 123456789 -123456790 123456 + +query IIIIII +SELECT ceil(123.45), ceil(-123.45), ceil(0.0), ceil(123456789.123), ceil(-123456789.123), ceil(123456.7891) +---- +124 -123 0 123456790 -123456789 123457 + + +query FFFFFFFFFF +SELECT truncate(123.4567, 2), truncate(-123.4567, 2), truncate(123.4567, 0), truncate(123.456789123, 6), truncate(0.0, 2), truncate(123456789.123, 2), truncate(-123456789.123, 2), truncate(123456.7891, 1), truncate(123456789012345.12345, 3), truncate(123.45, -1) +---- +123.45 -123.45 123 123.456789 0.0 123456789.12 -123456789.12 123456.7 123456789012345.123 120 + + +query FFFFFFFFFF +SELECT round(123.4567, 2), round(-123.4567, 2), round(123.455, 2), round(123.445, 2), round(123.456789123, 6), round(0.0, 2), round(123456789.123, 2), round(-123456789.123, 2), round(123456.7891, 1), round(123456.789, -2), round(-123456.789, -3), round(123456789012345.12345, 3) +---- +123.46 -123.46 123.46 123.45 123.456789 0.0 123456789.12 -123456789.12 123456.8 123500 -123000 123456789012345.123 From d8704bcb2cf578c77278321b1b7f733357ddc9fe Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Sun, 17 Dec 2023 00:09:31 +0800 Subject: [PATCH 3/7] chore(query): add tests --- src/query/functions/src/scalars/decimal.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/query/functions/src/scalars/decimal.rs b/src/query/functions/src/scalars/decimal.rs index 4018e6c65c0b..32d175cff099 100644 --- a/src/query/functions/src/scalars/decimal.rs +++ b/src/query/functions/src/scalars/decimal.rs @@ -1640,7 +1640,6 @@ fn decimal_to_int( } } -// round, truncate pub fn register_decimal_math(registry: &mut FunctionRegistry) { let factory = |params: &[usize], args_type: &[DataType], round_mode: RoundMode| { if args_type.is_empty() { From 1a7e330fd2a8db5edfd7815a69b9471e4e3e0ea5 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Sun, 17 Dec 2023 00:13:32 +0800 Subject: [PATCH 4/7] chore(query): add tests --- src/query/functions/src/scalars/decimal.rs | 30 ++++++---------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/src/query/functions/src/scalars/decimal.rs b/src/query/functions/src/scalars/decimal.rs index 32d175cff099..93366438783a 100644 --- a/src/query/functions/src/scalars/decimal.rs +++ b/src/query/functions/src/scalars/decimal.rs @@ -1667,7 +1667,7 @@ pub fn register_decimal_math(registry: &mut FunctionRegistry) { let dest_decimal_type = DecimalDataType::from_size(decimal_size).ok()?; let name = format!("{:?}", round_mode).to_lowercase(); - Some(Function { + let f = Function { signature: FunctionSignature { name, args_type: args_type.to_owned(), @@ -1685,44 +1685,30 @@ pub fn register_decimal_math(registry: &mut FunctionRegistry) { ) }), }, - }) + }; + + if args_type[0].is_nullable() { + Some(f.passthrough_nullable()) + } else { + Some(f) + } }; registry.register_function_factory("round", move |params, args_type| { Some(Arc::new(factory(params, args_type, RoundMode::Round)?)) }); - registry.register_function_factory("round", move |params, args_type| { - let f = factory(params, args_type, RoundMode::Round)?; - Some(Arc::new(f.passthrough_nullable())) - }); - registry.register_function_factory("truncate", move |params, args_type| { Some(Arc::new(factory(params, args_type, RoundMode::Truncate)?)) }); - registry.register_function_factory("truncate", move |params, args_type| { - let f = factory(params, args_type, RoundMode::Truncate)?; - Some(Arc::new(f.passthrough_nullable())) - }); - registry.register_function_factory("ceil", move |params, args_type| { Some(Arc::new(factory(params, args_type, RoundMode::Ceil)?)) }); - registry.register_function_factory("ceil", move |params, args_type| { - let f = factory(params, args_type, RoundMode::Ceil)?; - Some(Arc::new(f.passthrough_nullable())) - }); - registry.register_function_factory("floor", move |params, args_type| { Some(Arc::new(factory(params, args_type, RoundMode::Floor)?)) }); - - registry.register_function_factory("floor", move |params, args_type| { - let f = factory(params, args_type, RoundMode::Floor)?; - Some(Arc::new(f.passthrough_nullable())) - }); } #[derive(Copy, Clone, Debug)] From 192bb44277702c6a567c0efac77e6933037ab3ce Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Sun, 17 Dec 2023 00:16:31 +0800 Subject: [PATCH 5/7] chore(query): add tests --- src/query/functions/src/scalars/decimal.rs | 26 +++++++++------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/query/functions/src/scalars/decimal.rs b/src/query/functions/src/scalars/decimal.rs index 93366438783a..cb4172f75a1a 100644 --- a/src/query/functions/src/scalars/decimal.rs +++ b/src/query/functions/src/scalars/decimal.rs @@ -1694,21 +1694,17 @@ pub fn register_decimal_math(registry: &mut FunctionRegistry) { } }; - registry.register_function_factory("round", move |params, args_type| { - Some(Arc::new(factory(params, args_type, RoundMode::Round)?)) - }); - - registry.register_function_factory("truncate", move |params, args_type| { - Some(Arc::new(factory(params, args_type, RoundMode::Truncate)?)) - }); - - registry.register_function_factory("ceil", move |params, args_type| { - Some(Arc::new(factory(params, args_type, RoundMode::Ceil)?)) - }); - - registry.register_function_factory("floor", move |params, args_type| { - Some(Arc::new(factory(params, args_type, RoundMode::Floor)?)) - }); + for m in [ + RoundMode::Round, + RoundMode::Truncate, + RoundMode::Ceil, + RoundMode::Floor, + ] { + let name = format!("{:?}", m).to_lowercase(); + registry.register_function_factory(&name, move |params, args_type| { + Some(Arc::new(factory(params, args_type, m)?)) + }); + } } #[derive(Copy, Clone, Debug)] From 955079151317709f2060879fc167d0aedd5d27dc Mon Sep 17 00:00:00 2001 From: sundyli <543950155@qq.com> Date: Sat, 16 Dec 2023 17:48:54 +0800 Subject: [PATCH 6/7] fix(function): fix ceil function --- src/query/functions/src/scalars/decimal.rs | 4 +- .../it/scalars/testdata/function_list.txt | 208 +++++++++--------- 2 files changed, 105 insertions(+), 107 deletions(-) diff --git a/src/query/functions/src/scalars/decimal.rs b/src/query/functions/src/scalars/decimal.rs index cb4172f75a1a..406a48c1026d 100644 --- a/src/query/functions/src/scalars/decimal.rs +++ b/src/query/functions/src/scalars/decimal.rs @@ -1667,10 +1667,12 @@ pub fn register_decimal_math(registry: &mut FunctionRegistry) { let dest_decimal_type = DecimalDataType::from_size(decimal_size).ok()?; let name = format!("{:?}", round_mode).to_lowercase(); + let mut sig_args_type = args_type.to_owned(); + sig_args_type[0] = from_type.clone(); let f = Function { signature: FunctionSignature { name, - args_type: args_type.to_owned(), + args_type: sig_args_type, return_type: DataType::Decimal(dest_decimal_type), }, eval: FunctionEval::Scalar { diff --git a/src/query/functions/tests/it/scalars/testdata/function_list.txt b/src/query/functions/tests/it/scalars/testdata/function_list.txt index b7353f14cf2e..8b15ea41271a 100644 --- a/src/query/functions/tests/it/scalars/testdata/function_list.txt +++ b/src/query/functions/tests/it/scalars/testdata/function_list.txt @@ -759,27 +759,26 @@ Functions overloads: 18 cbrt(Float64) :: Float64 19 cbrt(Float64 NULL) :: Float64 NULL 0 ceil FACTORY -1 ceil FACTORY -2 ceil(UInt8) :: UInt8 -3 ceil(UInt8 NULL) :: UInt8 NULL -4 ceil(UInt16) :: UInt16 -5 ceil(UInt16 NULL) :: UInt16 NULL -6 ceil(UInt32) :: UInt32 -7 ceil(UInt32 NULL) :: UInt32 NULL -8 ceil(UInt64) :: UInt64 -9 ceil(UInt64 NULL) :: UInt64 NULL -10 ceil(Int8) :: Int8 -11 ceil(Int8 NULL) :: Int8 NULL -12 ceil(Int16) :: Int16 -13 ceil(Int16 NULL) :: Int16 NULL -14 ceil(Int32) :: Int32 -15 ceil(Int32 NULL) :: Int32 NULL -16 ceil(Int64) :: Int64 -17 ceil(Int64 NULL) :: Int64 NULL -18 ceil(Float32) :: Float64 -19 ceil(Float32 NULL) :: Float64 NULL -20 ceil(Float64) :: Float64 -21 ceil(Float64 NULL) :: Float64 NULL +1 ceil(UInt8) :: UInt8 +2 ceil(UInt8 NULL) :: UInt8 NULL +3 ceil(UInt16) :: UInt16 +4 ceil(UInt16 NULL) :: UInt16 NULL +5 ceil(UInt32) :: UInt32 +6 ceil(UInt32 NULL) :: UInt32 NULL +7 ceil(UInt64) :: UInt64 +8 ceil(UInt64 NULL) :: UInt64 NULL +9 ceil(Int8) :: Int8 +10 ceil(Int8 NULL) :: Int8 NULL +11 ceil(Int16) :: Int16 +12 ceil(Int16 NULL) :: Int16 NULL +13 ceil(Int32) :: Int32 +14 ceil(Int32 NULL) :: Int32 NULL +15 ceil(Int64) :: Int64 +16 ceil(Int64 NULL) :: Int64 NULL +17 ceil(Float32) :: Float64 +18 ceil(Float32 NULL) :: Float64 NULL +19 ceil(Float64) :: Float64 +20 ceil(Float64 NULL) :: Float64 NULL 0 char FACTORY 1 char FACTORY 0 char_length(String) :: UInt64 @@ -1646,9 +1645,8 @@ Functions overloads: 15 factorial(Int64 NULL) :: Int64 NULL 0 flatten FACTORY 0 floor FACTORY -1 floor FACTORY -2 floor(Float64) :: Float64 -3 floor(Float64 NULL) :: Float64 NULL +1 floor(Float64) :: Float64 +2 floor(Float64 NULL) :: Float64 NULL 0 from_base64(String) :: String 1 from_base64(String NULL) :: String NULL 0 gen_random_uuid() :: String @@ -3014,47 +3012,46 @@ Functions overloads: 0 right(String, UInt64) :: String 1 right(String NULL, UInt64 NULL) :: String NULL 0 round FACTORY -1 round FACTORY -2 round(UInt8) :: Float64 -3 round(UInt8 NULL) :: Float64 NULL -4 round(UInt8, Int64) :: Float64 -5 round(UInt8 NULL, Int64 NULL) :: Float64 NULL -6 round(UInt16) :: Float64 -7 round(UInt16 NULL) :: Float64 NULL -8 round(UInt16, Int64) :: Float64 -9 round(UInt16 NULL, Int64 NULL) :: Float64 NULL -10 round(UInt32) :: Float64 -11 round(UInt32 NULL) :: Float64 NULL -12 round(UInt32, Int64) :: Float64 -13 round(UInt32 NULL, Int64 NULL) :: Float64 NULL -14 round(UInt64) :: Float64 -15 round(UInt64 NULL) :: Float64 NULL -16 round(UInt64, Int64) :: Float64 -17 round(UInt64 NULL, Int64 NULL) :: Float64 NULL -18 round(Int8) :: Float64 -19 round(Int8 NULL) :: Float64 NULL -20 round(Int8, Int64) :: Float64 -21 round(Int8 NULL, Int64 NULL) :: Float64 NULL -22 round(Int16) :: Float64 -23 round(Int16 NULL) :: Float64 NULL -24 round(Int16, Int64) :: Float64 -25 round(Int16 NULL, Int64 NULL) :: Float64 NULL -26 round(Int32) :: Float64 -27 round(Int32 NULL) :: Float64 NULL -28 round(Int32, Int64) :: Float64 -29 round(Int32 NULL, Int64 NULL) :: Float64 NULL -30 round(Int64) :: Float64 -31 round(Int64 NULL) :: Float64 NULL -32 round(Int64, Int64) :: Float64 -33 round(Int64 NULL, Int64 NULL) :: Float64 NULL -34 round(Float32) :: Float64 -35 round(Float32 NULL) :: Float64 NULL -36 round(Float32, Int64) :: Float64 -37 round(Float32 NULL, Int64 NULL) :: Float64 NULL -38 round(Float64) :: Float64 -39 round(Float64 NULL) :: Float64 NULL -40 round(Float64, Int64) :: Float64 -41 round(Float64 NULL, Int64 NULL) :: Float64 NULL +1 round(UInt8) :: Float64 +2 round(UInt8 NULL) :: Float64 NULL +3 round(UInt8, Int64) :: Float64 +4 round(UInt8 NULL, Int64 NULL) :: Float64 NULL +5 round(UInt16) :: Float64 +6 round(UInt16 NULL) :: Float64 NULL +7 round(UInt16, Int64) :: Float64 +8 round(UInt16 NULL, Int64 NULL) :: Float64 NULL +9 round(UInt32) :: Float64 +10 round(UInt32 NULL) :: Float64 NULL +11 round(UInt32, Int64) :: Float64 +12 round(UInt32 NULL, Int64 NULL) :: Float64 NULL +13 round(UInt64) :: Float64 +14 round(UInt64 NULL) :: Float64 NULL +15 round(UInt64, Int64) :: Float64 +16 round(UInt64 NULL, Int64 NULL) :: Float64 NULL +17 round(Int8) :: Float64 +18 round(Int8 NULL) :: Float64 NULL +19 round(Int8, Int64) :: Float64 +20 round(Int8 NULL, Int64 NULL) :: Float64 NULL +21 round(Int16) :: Float64 +22 round(Int16 NULL) :: Float64 NULL +23 round(Int16, Int64) :: Float64 +24 round(Int16 NULL, Int64 NULL) :: Float64 NULL +25 round(Int32) :: Float64 +26 round(Int32 NULL) :: Float64 NULL +27 round(Int32, Int64) :: Float64 +28 round(Int32 NULL, Int64 NULL) :: Float64 NULL +29 round(Int64) :: Float64 +30 round(Int64 NULL) :: Float64 NULL +31 round(Int64, Int64) :: Float64 +32 round(Int64 NULL, Int64 NULL) :: Float64 NULL +33 round(Float32) :: Float64 +34 round(Float32 NULL) :: Float64 NULL +35 round(Float32, Int64) :: Float64 +36 round(Float32 NULL, Int64 NULL) :: Float64 NULL +37 round(Float64) :: Float64 +38 round(Float64 NULL) :: Float64 NULL +39 round(Float64, Int64) :: Float64 +40 round(Float64 NULL, Int64 NULL) :: Float64 NULL 0 rpad(String, UInt64, String) :: String 1 rpad(String NULL, UInt64 NULL, String NULL) :: String NULL 0 rtrim(String) :: String @@ -3654,47 +3651,46 @@ Functions overloads: 0 trim_trailing(String, String) :: String 1 trim_trailing(String NULL, String NULL) :: String NULL 0 truncate FACTORY -1 truncate FACTORY -2 truncate(UInt8) :: Float64 -3 truncate(UInt8 NULL) :: Float64 NULL -4 truncate(UInt8, Int64) :: Float64 -5 truncate(UInt8 NULL, Int64 NULL) :: Float64 NULL -6 truncate(UInt16) :: Float64 -7 truncate(UInt16 NULL) :: Float64 NULL -8 truncate(UInt16, Int64) :: Float64 -9 truncate(UInt16 NULL, Int64 NULL) :: Float64 NULL -10 truncate(UInt32) :: Float64 -11 truncate(UInt32 NULL) :: Float64 NULL -12 truncate(UInt32, Int64) :: Float64 -13 truncate(UInt32 NULL, Int64 NULL) :: Float64 NULL -14 truncate(UInt64) :: Float64 -15 truncate(UInt64 NULL) :: Float64 NULL -16 truncate(UInt64, Int64) :: Float64 -17 truncate(UInt64 NULL, Int64 NULL) :: Float64 NULL -18 truncate(Int8) :: Float64 -19 truncate(Int8 NULL) :: Float64 NULL -20 truncate(Int8, Int64) :: Float64 -21 truncate(Int8 NULL, Int64 NULL) :: Float64 NULL -22 truncate(Int16) :: Float64 -23 truncate(Int16 NULL) :: Float64 NULL -24 truncate(Int16, Int64) :: Float64 -25 truncate(Int16 NULL, Int64 NULL) :: Float64 NULL -26 truncate(Int32) :: Float64 -27 truncate(Int32 NULL) :: Float64 NULL -28 truncate(Int32, Int64) :: Float64 -29 truncate(Int32 NULL, Int64 NULL) :: Float64 NULL -30 truncate(Int64) :: Float64 -31 truncate(Int64 NULL) :: Float64 NULL -32 truncate(Int64, Int64) :: Float64 -33 truncate(Int64 NULL, Int64 NULL) :: Float64 NULL -34 truncate(Float32) :: Float64 -35 truncate(Float32 NULL) :: Float64 NULL -36 truncate(Float32, Int64) :: Float64 -37 truncate(Float32 NULL, Int64 NULL) :: Float64 NULL -38 truncate(Float64) :: Float64 -39 truncate(Float64 NULL) :: Float64 NULL -40 truncate(Float64, Int64) :: Float64 -41 truncate(Float64 NULL, Int64 NULL) :: Float64 NULL +1 truncate(UInt8) :: Float64 +2 truncate(UInt8 NULL) :: Float64 NULL +3 truncate(UInt8, Int64) :: Float64 +4 truncate(UInt8 NULL, Int64 NULL) :: Float64 NULL +5 truncate(UInt16) :: Float64 +6 truncate(UInt16 NULL) :: Float64 NULL +7 truncate(UInt16, Int64) :: Float64 +8 truncate(UInt16 NULL, Int64 NULL) :: Float64 NULL +9 truncate(UInt32) :: Float64 +10 truncate(UInt32 NULL) :: Float64 NULL +11 truncate(UInt32, Int64) :: Float64 +12 truncate(UInt32 NULL, Int64 NULL) :: Float64 NULL +13 truncate(UInt64) :: Float64 +14 truncate(UInt64 NULL) :: Float64 NULL +15 truncate(UInt64, Int64) :: Float64 +16 truncate(UInt64 NULL, Int64 NULL) :: Float64 NULL +17 truncate(Int8) :: Float64 +18 truncate(Int8 NULL) :: Float64 NULL +19 truncate(Int8, Int64) :: Float64 +20 truncate(Int8 NULL, Int64 NULL) :: Float64 NULL +21 truncate(Int16) :: Float64 +22 truncate(Int16 NULL) :: Float64 NULL +23 truncate(Int16, Int64) :: Float64 +24 truncate(Int16 NULL, Int64 NULL) :: Float64 NULL +25 truncate(Int32) :: Float64 +26 truncate(Int32 NULL) :: Float64 NULL +27 truncate(Int32, Int64) :: Float64 +28 truncate(Int32 NULL, Int64 NULL) :: Float64 NULL +29 truncate(Int64) :: Float64 +30 truncate(Int64 NULL) :: Float64 NULL +31 truncate(Int64, Int64) :: Float64 +32 truncate(Int64 NULL, Int64 NULL) :: Float64 NULL +33 truncate(Float32) :: Float64 +34 truncate(Float32 NULL) :: Float64 NULL +35 truncate(Float32, Int64) :: Float64 +36 truncate(Float32 NULL, Int64 NULL) :: Float64 NULL +37 truncate(Float64) :: Float64 +38 truncate(Float64 NULL) :: Float64 NULL +39 truncate(Float64, Int64) :: Float64 +40 truncate(Float64 NULL, Int64 NULL) :: Float64 NULL 0 try_inet_aton(String) :: UInt32 NULL 1 try_inet_aton(String NULL) :: UInt32 NULL 0 try_inet_ntoa(Int64) :: String NULL From 98b8daa55b4198117d6cbecb48ffce3fad79b761 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Sun, 17 Dec 2023 03:59:43 +0800 Subject: [PATCH 7/7] chore(query): fix tests --- src/query/functions/src/scalars/decimal.rs | 9 +- tests/sqllogictests/suites/tpcds/queries.test | 628 +++++++++--------- tests/sqllogictests/suites/tpch/queries.test | 50 +- 3 files changed, 343 insertions(+), 344 deletions(-) diff --git a/src/query/functions/src/scalars/decimal.rs b/src/query/functions/src/scalars/decimal.rs index 406a48c1026d..78618cc8720e 100644 --- a/src/query/functions/src/scalars/decimal.rs +++ b/src/query/functions/src/scalars/decimal.rs @@ -1821,11 +1821,10 @@ where T: Decimal values .iter() .map(|input| { - match input.cmp(&T::zero()) { - // below 0 we floor the number (e.g. -10.5 -> -10) - std::cmp::Ordering::Less => *input / power_of_ten, - std::cmp::Ordering::Equal => T::zero(), - std::cmp::Ordering::Greater => ((*input - T::one()) / power_of_ten) + T::one(), + if input <= &T::zero() { + *input / power_of_ten + } else { + ((*input - T::one()) / power_of_ten) + T::one() } }) .collect() diff --git a/tests/sqllogictests/suites/tpcds/queries.test b/tests/sqllogictests/suites/tpcds/queries.test index 3582c9dceeb2..042890ab6a4d 100644 --- a/tests/sqllogictests/suites/tpcds/queries.test +++ b/tests/sqllogictests/suites/tpcds/queries.test @@ -215,62 +215,62 @@ FROM WHERE d_week_seq1 = d_week_seq2-53 ORDER BY d_week_seq1 NULLS FIRST; ---- -5270 NULL 2.6 NULL 0.71 2.48 NULL NULL -5270 NULL 2.6 NULL 0.71 2.48 NULL NULL -5270 NULL 2.6 NULL 0.71 2.48 NULL NULL -5270 NULL 2.6 NULL 0.71 2.48 NULL NULL -5270 NULL 2.6 NULL 0.71 2.48 NULL NULL -5270 NULL 2.6 NULL 0.71 2.48 NULL NULL -5270 NULL 2.6 NULL 0.71 2.48 NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL -5271 NULL NULL 0.5 NULL NULL NULL NULL +5270 NULL 2.60 NULL 0.71 2.48 NULL NULL +5270 NULL 2.60 NULL 0.71 2.48 NULL NULL +5270 NULL 2.60 NULL 0.71 2.48 NULL NULL +5270 NULL 2.60 NULL 0.71 2.48 NULL NULL +5270 NULL 2.60 NULL 0.71 2.48 NULL NULL +5270 NULL 2.60 NULL 0.71 2.48 NULL NULL +5270 NULL 2.60 NULL 0.71 2.48 NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL +5271 NULL NULL 0.50 NULL NULL NULL NULL 5272 NULL NULL NULL 0.52 1.42 NULL 0.49 5272 NULL NULL NULL 0.52 1.42 NULL 0.49 5272 NULL NULL NULL 0.52 1.42 NULL 0.49 @@ -761,55 +761,55 @@ ORDER BY d_week_seq1 NULLS FIRST; 5284 NULL NULL 2.98 2.93 NULL 0.69 1.95 5284 NULL NULL 2.98 2.93 NULL 0.69 1.95 5284 NULL NULL 2.98 2.93 NULL 0.69 1.95 -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL -5285 0.8 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL +5285 0.80 0.71 NULL NULL NULL NULL NULL 5286 1.62 NULL NULL NULL NULL NULL NULL 5286 1.62 NULL NULL NULL NULL NULL NULL 5286 1.62 NULL NULL NULL NULL NULL NULL @@ -859,55 +859,55 @@ ORDER BY d_week_seq1 NULLS FIRST; 5286 1.62 NULL NULL NULL NULL NULL NULL 5286 1.62 NULL NULL NULL NULL NULL NULL 5286 1.62 NULL NULL NULL NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL -5287 NULL NULL NULL 1.9 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL +5287 NULL NULL NULL 1.90 NULL NULL NULL 5288 1.17 NULL NULL NULL NULL NULL NULL 5288 1.17 NULL NULL NULL NULL NULL NULL 5288 1.17 NULL NULL NULL NULL NULL NULL @@ -1251,55 +1251,55 @@ ORDER BY d_week_seq1 NULLS FIRST; 5300 NULL 0.93 NULL NULL NULL 2.01 NULL 5300 NULL 0.93 NULL NULL NULL 2.01 NULL 5300 NULL 0.93 NULL NULL NULL 2.01 NULL -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 -5301 NULL 0.81 2.66 0.7 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 +5301 NULL 0.81 2.66 0.70 NULL 1.91 0.07 5302 NULL NULL NULL 0.18 NULL NULL NULL 5302 NULL NULL NULL 0.18 NULL NULL NULL 5302 NULL NULL NULL 0.18 NULL NULL NULL @@ -1398,55 +1398,55 @@ ORDER BY d_week_seq1 NULLS FIRST; 5304 NULL NULL 3.64 NULL NULL NULL NULL 5304 NULL NULL 3.64 NULL NULL NULL NULL 5304 NULL NULL 3.64 NULL NULL NULL NULL -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 -5305 0.97 2.21 1.2 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 +5305 0.97 2.21 1.20 NULL 1.05 NULL 0.41 5306 NULL 1.92 NULL NULL NULL NULL NULL 5306 NULL 1.92 NULL NULL NULL NULL NULL 5306 NULL 1.92 NULL NULL NULL NULL NULL @@ -2035,55 +2035,55 @@ ORDER BY d_week_seq1 NULLS FIRST; 5318 NULL NULL NULL NULL NULL NULL 0.29 5318 NULL NULL NULL NULL NULL NULL 0.29 5318 NULL NULL NULL NULL NULL NULL 0.29 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 -5319 NULL NULL NULL NULL NULL NULL 0.8 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 +5319 NULL NULL NULL NULL NULL NULL 0.80 5320 NULL NULL NULL NULL NULL 1.87 NULL 5320 NULL NULL NULL NULL NULL 1.87 NULL 5320 NULL NULL NULL NULL NULL 1.87 NULL @@ -8493,7 +8493,7 @@ LIMIT 100; 2000 8 501 1.69 71 88.22 88.76 42 59.15 33.59 2000 8 568 5.69 91 106.86 72.31 16 88.70 22.13 2000 8 607 1.24 94 69.87 8.44 76 15.60 12.40 -2000 8 937 4.0 32 28.49 43.91 8 35.73 79.14 +2000 8 937 4.00 32 28.49 43.91 8 35.73 79.14 2000 11 99 3.17 73 35.63 42.50 23 82.52 81.30 2000 11 344 0.98 79 55.29 9.50 81 60.39 6.55 2000 11 937 1.46 95 65.04 109.88 65 69.73 181.29 @@ -8505,20 +8505,20 @@ LIMIT 100; 2000 19 539 0.49 33 32.33 41.35 68 124.61 67.61 2000 19 566 0.61 53 80.97 85.69 87 80.36 84.40 2000 19 682 0.48 47 58.06 39.08 97 13.10 18.56 -2000 19 922 26.5 53 32.46 10.43 2 36.78 51.51 +2000 19 922 26.50 53 32.46 10.43 2 36.78 51.51 2000 20 321 2.38 31 17.31 17.66 13 84.13 160.90 -2000 20 501 0.3 10 4.27 1.33 33 12.91 0.30 +2000 20 501 0.30 10 4.27 1.33 33 12.91 0.30 2000 20 822 1.17 69 86.20 136.53 59 61.54 130.02 2000 25 665 0.11 7 31.24 17.68 65 85.15 143.04 2000 26 354 0.19 18 5.00 4.84 96 89.99 166.35 -2000 26 498 0.4 24 57.11 26.55 60 85.59 76.73 +2000 26 498 0.40 24 57.11 26.55 60 85.59 76.73 2000 26 784 0.95 69 7.68 5.25 73 76.72 121.29 2000 26 878 2.07 58 7.20 4.41 28 53.28 28.79 -2000 29 65 16.4 82 18.74 2.16 5 81.49 12.09 +2000 29 65 16.40 82 18.74 2.16 5 81.49 12.09 2000 29 335 0.35 32 76.21 8.09 91 2.15 1.16 2000 29 501 1.76 86 37.64 18.80 49 95.25 65.69 2000 29 843 1.04 73 59.61 61.15 70 23.06 20.37 -2000 29 990 0.2 10 62.00 53.94 49 88.35 21.73 +2000 29 990 0.20 10 62.00 53.94 49 88.35 21.73 2000 29 994 0.53 16 94.38 60.13 30 1.47 1.36 2000 31 4 0.93 13 87.20 36.16 14 81.43 75.69 2000 31 182 0.38 29 66.79 45.75 77 51.10 66.77 @@ -8544,7 +8544,7 @@ LIMIT 100; 2000 49 445 1.17 91 79.33 2.74 78 49.74 9.40 2000 50 193 2.41 94 63.22 32.52 39 1.80 1.71 2000 50 194 0.23 22 97.27 177.37 94 25.46 54.04 -2000 50 391 0.2 16 59.10 37.51 81 96.87 94.94 +2000 50 391 0.20 16 59.10 37.51 81 96.87 94.94 2000 50 393 1.05 67 82.86 21.75 64 82.54 154.31 2000 50 962 2.63 84 4.69 1.01 32 62.01 101.08 2000 50 985 0.26 24 17.04 8.34 93 20.29 33.41 @@ -8563,23 +8563,23 @@ LIMIT 100; 2000 61 602 0.13 7 57.58 54.01 52 65.10 28.35 2000 61 684 0.53 51 5.35 1.50 97 63.81 16.25 2000 61 982 0.09 7 26.83 25.22 74 43.88 69.07 -2000 62 498 0.3 27 55.17 36.57 89 2.42 2.17 -2000 65 169 9.4 47 93.06 109.67 5 36.69 51.72 +2000 62 498 0.30 27 55.17 36.57 89 2.42 2.17 +2000 65 169 9.40 47 93.06 109.67 5 36.69 51.72 2000 65 182 4.67 56 19.06 12.63 12 98.17 137.55 2000 65 928 0.48 25 13.75 5.51 52 57.55 32.87 2000 65 933 0.86 79 86.28 132.10 92 94.69 187.89 -2000 67 94 2.5 35 28.17 13.23 14 39.29 37.31 -2000 67 761 12.2 61 20.72 9.13 5 27.61 25.35 +2000 67 94 2.50 35 28.17 13.23 14 39.29 37.31 +2000 67 761 12.20 61 20.72 9.13 5 27.61 25.35 2000 67 841 1.01 79 41.08 29.17 78 25.77 34.78 2000 67 878 0.83 76 22.82 14.77 92 82.50 100.75 -2000 68 37 0.1 9 94.94 67.67 91 74.13 130.52 +2000 68 37 0.10 9 94.94 67.67 91 74.13 130.52 2000 68 65 2.76 69 15.89 4.09 25 25.80 22.95 2000 68 122 1.95 76 28.79 1.18 39 17.33 22.92 2000 68 375 2.88 95 30.91 20.69 33 84.01 46.92 2000 68 391 5.64 62 53.06 37.93 11 25.78 37.76 2000 68 808 2.28 41 25.44 0.45 18 89.72 117.53 2000 71 668 0.89 65 43.58 8.59 73 68.38 9.23 -2000 73 596 3.7 74 69.38 6.32 20 88.71 1.33 +2000 73 596 3.70 74 69.38 6.32 20 88.71 1.33 # Q79 onlyif mysql diff --git a/tests/sqllogictests/suites/tpch/queries.test b/tests/sqllogictests/suites/tpch/queries.test index df4fe3cadce9..fa4dc273e1a3 100644 --- a/tests/sqllogictests/suites/tpch/queries.test +++ b/tests/sqllogictests/suites/tpch/queries.test @@ -237,11 +237,11 @@ group by order by revenue desc; ---- -CHINA 782211.0 -INDIA 637613.0 -JAPAN 600008.0 -INDONESIA 558048.0 -VIETNAM 449785.0 +CHINA 782211 +INDIA 637613 +JAPAN 600008 +INDONESIA 558048 +VIETNAM 449785 # Q6 query I @@ -255,7 +255,7 @@ where and l_discount between 0.05 and 0.07 and l_quantity < 24; ---- -11803420.0 +11803420.253 # Q7 query I @@ -299,10 +299,10 @@ order by cust_nation, l_year; ---- -FRANCE GERMANY 1995 4637235.0 -FRANCE GERMANY 1996 5224780.0 -GERMANY FRANCE 1995 6232819.0 -GERMANY FRANCE 1996 5557312.5 +FRANCE GERMANY 1995 4637235.150 +FRANCE GERMANY 1996 5224779.573 +GERMANY FRANCE 1995 6232818.703 +GERMANY FRANCE 1996 5557312.112 # Q8 query I @@ -382,11 +382,11 @@ order by sum_profit limit 5; ---- -MOZAMBIQUE 1998 162042.0 -JORDAN 1998 181148.0 -MOROCCO 1998 181533.0 -JAPAN 1998 184953.0 -VIETNAM 1998 192431.0 +MOZAMBIQUE 1998 162042 +JORDAN 1998 181148 +MOROCCO 1998 181533 +JAPAN 1998 184953 +VIETNAM 1998 192431 # Q10 query I @@ -422,11 +422,11 @@ group by order by revenue desc limit 5; ---- -8242 Customer#000008242 622786.687 6322.09 ETHIOPIA P2n4nJhy,UqSo2s43YfSvYJDZ6lk 15-792-676-1184 slyly regular packages haggle carefully ironic ideas. courts are furiously. furiously unusual theodolites cajole. i -7714 Customer#000007714 557400.312 9799.98 IRAN SnnIGB,SkmnWpX3 20-922-418-6024 arhorses according to the blithely express re -11032 Customer#000011032 512500.937 8496.93 UNITED KINGDOM WIKHC7K3Cn7156iNOyfVG3cZ7YqkgsR,Ly 33-102-772-3533 posits-- furiously ironic accounts are again -2455 Customer#000002455 481592.437 2070.99 GERMANY RVn1ZSRtLqPlJLIZxvpmsbgC02 17-946-225-9977 al asymptotes. finally ironic accounts cajole furiously. permanently unusual theodolites aro -12106 Customer#000012106 479414.218 5342.11 UNITED STATES wth3twOmu6vy 34-905-346-4472 ly after the blithely regular foxes. accounts haggle carefully alongside of the blithely even ideas. +8242 Customer#000008242 622786.729 6322.09 ETHIOPIA P2n4nJhy,UqSo2s43YfSvYJDZ6lk 15-792-676-1184 slyly regular packages haggle carefully ironic ideas. courts are furiously. furiously unusual theodolites cajole. i +7714 Customer#000007714 557400.305 9799.98 IRAN SnnIGB,SkmnWpX3 20-922-418-6024 arhorses according to the blithely express re +11032 Customer#000011032 512500.964 8496.93 UNITED KINGDOM WIKHC7K3Cn7156iNOyfVG3cZ7YqkgsR,Ly 33-102-772-3533 posits-- furiously ironic accounts are again +2455 Customer#000002455 481592.405 2070.99 GERMANY RVn1ZSRtLqPlJLIZxvpmsbgC02 17-946-225-9977 al asymptotes. finally ironic accounts cajole furiously. permanently unusual theodolites aro +12106 Customer#000012106 479414.213 5342.11 UNITED STATES wth3twOmu6vy 34-905-346-4472 ly after the blithely regular foxes. accounts haggle carefully alongside of the blithely even ideas. # Q11 query I @@ -708,7 +708,7 @@ where order by s_suppkey; ---- -677 Supplier#000000677 8mhrffG7D2WJBSQbOGstQ 23-290-639-3315 1614410.37 +677 Supplier#000000677 8mhrffG7D2WJBSQbOGstQ 23-290-639-3315 1614410.29 # Q15 with materialized cte query I @@ -743,7 +743,7 @@ where order by s_suppkey; ---- -677 Supplier#000000677 8mhrffG7D2WJBSQbOGstQ 23-290-639-3315 1614410.37 +677 Supplier#000000677 8mhrffG7D2WJBSQbOGstQ 23-290-639-3315 1614410.29 # Q16 @@ -821,7 +821,7 @@ where l_partkey = p_partkey ); ---- -23512.75195312 +23512.75285714 #Q17 variant query I @@ -843,7 +843,7 @@ WHERE l_partkey = p_partkey ) ---- -23512.75195312 +23512.75285714 #Q18 query I @@ -958,7 +958,7 @@ where ) ; ---- -350370.468 +350370.483 # Q20 query I