Apache DataFusion SQL Query Engine
fix: keep decimal precision for SLT tests (#24934)
theirix9442d88c57d4
diff --git a/Cargo.lock b/Cargo.lockindex 293ac45c51..4b4aed82df 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2689,6 +2689,7 @@ dependencies = ["indicatif","itertools 0.15.0","log",+ "num-traits","object_store","postgres-types","regex",diff --git a/datafusion/sqllogictest/Cargo.toml b/datafusion/sqllogictest/Cargo.tomlindex 13493d16c0..c43f78f846 100644--- a/datafusion/sqllogictest/Cargo.toml+++ b/datafusion/sqllogictest/Cargo.toml@@ -54,6 +54,7 @@ half = { workspace = true, default-features = true }indicatif = "0.18"itertools = { workspace = true }log = { workspace = true }+num-traits = { workspace = true }object_store = { workspace = true }postgres-types = { version = "0.2.13", features = ["derive", "with-chrono-0_4"], optional = true }# When updating the following dependency verify that sqlite test file regeneration works correctlydiff --git a/datafusion/sqllogictest/README.md b/datafusion/sqllogictest/README.mdindex ca00fff7f6..cad15ef3a3 100644--- a/datafusion/sqllogictest/README.md+++ b/datafusion/sqllogictest/README.md@@ -449,7 +449,7 @@ query <type_string> <sort_mode>- 'T' - **T**ext,- "?" - any other types- `expected_result`: In the results section, some values are converted according to some rules:- - floating point values are rounded to the scale of "12",+ - floating point values are rounded to the scale of "12" and "15" for Spark,- NULL values are rendered as `NULL`,- empty strings are rendered as `(empty)`,- boolean values are rendered as `true`/`false`,diff --git a/datafusion/sqllogictest/src/engines/conversion.rs b/datafusion/sqllogictest/src/engines/conversion.rsindex 10d8285b63..d22b518234 100644--- a/datafusion/sqllogictest/src/engines/conversion.rs+++ b/datafusion/sqllogictest/src/engines/conversion.rs@@ -18,6 +18,7 @@use arrow::datatypes::DecimalType;use bigdecimal::BigDecimal;use half::f16;+use num_traits::Float;use std::str::FromStr;/// Represents a constant for NULL string in your database.@@ -40,158 +41,89 @@ pub(crate) fn varchar_to_str(value: &str) -> String {}}-pub(crate) fn f16_to_str(value: f16) -> String {+/// Decimal places to keep in floats for string representation.+const FLOAT_ROUND_DIGITS: i64 = 12;++/// Decimal places to keep in floats for Spark (derived from expm1 behaviour)+const SPARK_FLOAT_ROUND_DIGITS: i64 = 15;++pub(crate) fn float_to_str<T: Float + ToString>(value: T, round_digits: i64) -> String {if value.is_nan() {// The sign of NaN can be different depending on platform.// So the string representation of NaN ignores the sign."NaN".to_string()- } else if value == f16::INFINITY {+ } else if value == T::infinity() {"Infinity".to_string()- } else if value == f16::NEG_INFINITY {+ } else if value == T::neg_infinity() {"-Infinity".to_string()} else {- big_decimal_to_str(BigDecimal::from_str(&value.to_string()).unwrap(), None)+ float_decimal_to_str(value, round_digits)}}+pub(crate) fn f16_to_str(value: f16) -> String {+ float_to_str(value, FLOAT_ROUND_DIGITS)+}+pub(crate) fn f32_to_str(value: f32) -> String {- if value.is_nan() {- // The sign of NaN can be different depending on platform.- // So the string representation of NaN ignores the sign.- "NaN".to_string()- } else if value == f32::INFINITY {- "Infinity".to_string()- } else if value == f32::NEG_INFINITY {- "-Infinity".to_string()- } else {- big_decimal_to_str(BigDecimal::from_str(&value.to_string()).unwrap(), None)- }+ float_to_str(value, FLOAT_ROUND_DIGITS)}pub(crate) fn f64_to_str(value: f64) -> String {- if value.is_nan() {- // The sign of NaN can be different depending on platform.- // So the string representation of NaN ignores the sign.- "NaN".to_string()- } else if value == f64::INFINITY {- "Infinity".to_string()- } else if value == f64::NEG_INFINITY {- "-Infinity".to_string()- } else {- big_decimal_to_str(BigDecimal::from_str(&value.to_string()).unwrap(), None)- }+ float_to_str(value, FLOAT_ROUND_DIGITS)}pub(crate) fn spark_f64_to_str(value: f64) -> String {- if value.is_nan() {- // The sign of NaN can be different depending on platform.- // So the string representation of NaN ignores the sign.- "NaN".to_string()- } else if value == f64::INFINITY {- "Infinity".to_string()- } else if value == f64::NEG_INFINITY {- "-Infinity".to_string()- } else {- big_decimal_to_str(BigDecimal::from_str(&value.to_string()).unwrap(), Some(15))- }+ // Spark uses 15 decimal places for doubles+ float_to_str(value, SPARK_FLOAT_ROUND_DIGITS)}+/// Converts a float to its plain string representation, rounding to a specified number of decimal places.+fn float_decimal_to_str<T: Float + ToString>(value: T, round_digits: i64) -> String {+ let bd = BigDecimal::from_str(&value.to_string()).unwrap();+ // Round the value to limit the number of decimal places+ let value = bd.round(round_digits).normalized();+ // Format the value to a string+ value.to_plain_string()+}++/// Converts a decimal to its plain string representation, using the given scalepub(crate) fn arrow_decimal_to_str<T: DecimalType>(value: T::Native,scale: i8,) -> String {- let precision = u8::MAX; // does not matter- let value = T::format_decimal(value, precision, scale);- big_decimal_to_str(- BigDecimal::from_str(&value).unwrap(),- Some(i64::from(scale)),- )+ T::format_decimal(value, u8::MAX, scale)}#[cfg(feature = "postgres")]pub(crate) fn decimal_to_str(value: BigDecimal) -> String {- big_decimal_to_str(value, None)-}--/// Converts a `BigDecimal` to its plain string representation, optionally rounding to a specified number of decimal places.-///-/// If `round_digits` is `None`, the value is rounded to 12 decimal places by default.-#[expect(clippy::needless_pass_by_value)]-pub(crate) fn big_decimal_to_str(value: BigDecimal, round_digits: Option<i64>) -> String {- // Round the value to limit the number of decimal places- let value = value.round(round_digits.unwrap_or(12)).normalized();- // Format the value to a stringvalue.to_plain_string()}#[cfg(test)]mod tests {- use super::{arrow_decimal_to_str, big_decimal_to_str};+ use super::*;use arrow::datatypes::{- Decimal32Type, Decimal64Type, Decimal128Type, Decimal256Type, i256,+ DECIMAL128_MAX_SCALE, Decimal32Type, Decimal64Type, Decimal128Type,+ Decimal256Type, i256,};- use bigdecimal::{BigDecimal, num_bigint::BigInt};-- macro_rules! assert_decimal_str_eq {- ($integer:expr, $scale:expr, $round_digits:expr, $expected:expr) => {- assert_eq!(- big_decimal_to_str(- BigDecimal::from_bigint(BigInt::from($integer), $scale),- $round_digits- ),- $expected- );- };- }#[test]- fn test_big_decimal_to_str() {- assert_decimal_str_eq!(110, 3, None, "0.11");- assert_decimal_str_eq!(11, 3, None, "0.011");- assert_decimal_str_eq!(11, 2, None, "0.11");- assert_decimal_str_eq!(11, 1, None, "1.1");- assert_decimal_str_eq!(11, 0, None, "11");- assert_decimal_str_eq!(11, -1, None, "110");- assert_decimal_str_eq!(0, 0, None, "0");- assert_decimal_str_eq!(- 12345678901234567890123456789012345678_i128,- 0,- None,- "12345678901234567890123456789012345678"- );- assert_decimal_str_eq!(- 12345678901234567890123456789012345678_i128,- 38,- None,- "0.123456789012"- );-- // Negative cases- assert_decimal_str_eq!(-110, 3, None, "-0.11");- assert_decimal_str_eq!(-11, 3, None, "-0.011");- assert_decimal_str_eq!(-11, 2, None, "-0.11");- assert_decimal_str_eq!(-11, 1, None, "-1.1");- assert_decimal_str_eq!(-11, 0, None, "-11");- assert_decimal_str_eq!(-11, -1, None, "-110");- assert_decimal_str_eq!(- -12345678901234567890123456789012345678_i128,- 0,- None,- "-12345678901234567890123456789012345678"- );- assert_decimal_str_eq!(- -12345678901234567890123456789012345678_i128,- 38,- None,- "-0.123456789012"- );-- // Round to 12 decimal places- // 1.0000000000011 -> 1.000000000001- assert_decimal_str_eq!(10_i128.pow(13) + 11, 13, None, "1.000000000001");- assert_decimal_str_eq!(10_i128.pow(13) + 11, 13, Some(12), "1.000000000001");-- assert_decimal_str_eq!(10_i128.pow(13) + 11, 13, Some(13), "1.0000000000011");+ fn test_float_decimal_to_str() {+ assert_eq!(f64_to_str(0.11), "0.11");+ assert_eq!(f64_to_str(0.011), "0.011");+ assert_eq!(f64_to_str(1.1), "1.1");+ assert_eq!(f64_to_str(11.0), "11");+ assert_eq!(f64_to_str(-0.11), "-0.11");+ assert_eq!(f64_to_str(-0.011), "-0.011");+ assert_eq!(f64_to_str(-1.1,), "-1.1");+ assert_eq!(f64_to_str(-11.0), "-11");+ // Keep 12 decimal places+ assert_eq!(f64_to_str(0.12345678901234567), "0.123456789012");++ assert_eq!(spark_f64_to_str(-0.011), "-0.011");+ // Keep 15 decimal places for Spark+ assert_eq!(spark_f64_to_str(0.12345678901234567), "0.123456789012346");}#[test]@@ -203,5 +135,31 @@ mod tests {arrow_decimal_to_str::<Decimal256Type>(i256::from(12345), 2),"123.45");+ // Ensure it doesn't trim trailing zeros+ assert_eq!(arrow_decimal_to_str::<Decimal128Type>(12300, 2), "123.00");+ assert_eq!(arrow_decimal_to_str::<Decimal128Type>(12300, 4), "1.2300");++ // Keep full precision besides 12 decimal places+ assert_eq!(+ arrow_decimal_to_str::<Decimal128Type>(10_i128.pow(13) + 11, 13),+ "1.0000000000011"+ );++ // Zero-scale integers+ assert_eq!(+ arrow_decimal_to_str::<Decimal128Type>(+ 12345678901234567890123456789012345678_i128,+ 0+ ),+ "12345678901234567890123456789012345678"+ );+ // Keep full precision+ assert_eq!(+ arrow_decimal_to_str::<Decimal128Type>(+ 12345678901234567890123456789012345678_i128,+ DECIMAL128_MAX_SCALE+ ),+ "0.12345678901234567890123456789012345678"+ );}}diff --git a/datafusion/sqllogictest/test_files/aggregate.slt b/datafusion/sqllogictest/test_files/aggregate.sltindex 0e8d1eec80..5652982176 100644--- a/datafusion/sqllogictest/test_files/aggregate.slt+++ b/datafusion/sqllogictest/test_files/aggregate.slt@@ -3465,7 +3465,7 @@ create table t (c1 decimal(10, 0)) as values (1), (2), (3), (4), (5), (6);query RTselect avg(c1), arrow_typeof(avg(c1)) from t;-----3.5 Decimal128(14, 4)+3.5000 Decimal128(14, 4)statement okdrop table t;@@ -3477,7 +3477,7 @@ create table t (c1 decimal(10, 0)) as values (1), (NULL), (3), (4), (5);query RTselect avg(c1), arrow_typeof(avg(c1)) from t;-----3.25 Decimal128(14, 4)+3.2500 Decimal128(14, 4)statement okdrop table t;@@ -4633,27 +4633,27 @@ CREATE TABLE t (c DECIMAL(10, 2)) AS VALUES (10.10), (20.20), (30.30), (40.40),query RTSELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY c), arrow_typeof(percentile_cont(0.5) WITHIN GROUP (ORDER BY c)) FROM t-----30.3 Decimal128(10, 2)+30.30 Decimal128(10, 2)query RSELECT percentile_cont(0.25) WITHIN GROUP (ORDER BY c) FROM t-----20.2+20.20query RSELECT percentile_cont(0.75) WITHIN GROUP (ORDER BY c) FROM t-----40.4+40.40query RSELECT percentile_cont(0.0) WITHIN GROUP (ORDER BY c) FROM t-----10.1+10.10query RSELECT percentile_cont(1.0) WITHIN GROUP (ORDER BY c) FROM t-----50.5+50.50# Alternate syntax should agree with WITHIN GROUP syntaxquery B@@ -4671,17 +4671,17 @@ CREATE TABLE t (c DECIMAL(10, 2)) AS VALUES (10.00), (20.00);query RTSELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY c), arrow_typeof(percentile_cont(0.5) WITHIN GROUP (ORDER BY c)) FROM t-----15 Decimal128(10, 2)+15.00 Decimal128(10, 2)query RSELECT percentile_cont(0.25) WITHIN GROUP (ORDER BY c) FROM t-----12.5+12.50query RSELECT percentile_cont(0.75) WITHIN GROUP (ORDER BY c) FROM t-----17.5+17.50statement okDROP TABLE t;@@ -4693,12 +4693,12 @@ CREATE TABLE t (c DECIMAL(10, 2)) AS VALUES (-10.00), (-5.00), (0.00), (5.00), (query RSELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY c) FROM t-----0+0.00query RSELECT percentile_cont(0.25) WITHIN GROUP (ORDER BY c) FROM t------5+-5.00statement okDROP TABLE t;@@ -4722,7 +4722,7 @@ CREATE TABLE t (c DECIMAL(10, 2)) AS VALUES (42.00);query RSELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY c) FROM t-----42+42.00statement okDROP TABLE t;@@ -4734,8 +4734,8 @@ CREATE TABLE t (g INT, c DECIMAL(10, 2)) AS VALUES (1, 10.00), (1, 20.00), (2, 3query IRSELECT g, percentile_cont(0.5) WITHIN GROUP (ORDER BY c) FROM t GROUP BY g ORDER BY g-----1 15-2 40+1 15.00+2 40.00statement okDROP TABLE t;@@ -4747,12 +4747,12 @@ CREATE TABLE t (c DECIMAL(10, 2)) AS VALUES (10.00), (10.00), (10.00), (10.00),query RSELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY c) FROM t-----10+10.00query RTSELECT percentile_cont(DISTINCT c, 0.5), arrow_typeof(percentile_cont(DISTINCT c, 0.5)) FROM t-----15 Decimal128(10, 2)+15.00 Decimal128(10, 2)statement okDROP TABLE t;@@ -4763,19 +4763,19 @@ query RTSELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY v), arrow_typeof(percentile_cont(0.5) WITHIN GROUP (ORDER BY v))FROM (VALUES (arrow_cast(10.00, 'Decimal32(9, 2)')), (arrow_cast(20.00, 'Decimal32(9, 2)'))) as t (v)-----15 Decimal32(9, 2)+15.00 Decimal32(9, 2)query RTSELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY v), arrow_typeof(percentile_cont(0.5) WITHIN GROUP (ORDER BY v))FROM (VALUES (arrow_cast(10.00, 'Decimal64(18, 2)')), (arrow_cast(20.00, 'Decimal64(18, 2)'))) as t (v)-----15 Decimal64(18, 2)+15.00 Decimal64(18, 2)query RTSELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY v), arrow_typeof(percentile_cont(0.5) WITHIN GROUP (ORDER BY v))FROM (VALUES (arrow_cast(10.00, 'Decimal256(54, 6)')), (arrow_cast(20.00, 'Decimal256(54, 6)'))) as t (v)-----15 Decimal256(54, 6)+15.000000 Decimal256(54, 6)# Other decimals: GROUP BY and DISTINCT@@ -4789,8 +4789,8 @@ SELECT g,arrow_typeof(percentile_cont(arrow_cast(c, 'Decimal32(9, 2)'), 0.5))FROM t GROUP BY g ORDER BY g-----1 10 Decimal32(9, 2)-2 35 Decimal32(9, 2)+1 10.00 Decimal32(9, 2)+2 35.00 Decimal32(9, 2)query RRTSELECT@@ -4799,7 +4799,7 @@ SELECTarrow_typeof(percentile_cont(DISTINCT arrow_cast(c, 'Decimal32(9, 2)'), 0.5))FROM t-----15 25 Decimal32(9, 2)+15.00 25.00 Decimal32(9, 2)query IRTSELECT g,@@ -4807,8 +4807,8 @@ SELECT g,arrow_typeof(percentile_cont(arrow_cast(c, 'Decimal64(18, 2)'), 0.5))FROM t GROUP BY g ORDER BY g-----1 10 Decimal64(18, 2)-2 35 Decimal64(18, 2)+1 10.00 Decimal64(18, 2)+2 35.00 Decimal64(18, 2)query RRTSELECT@@ -4817,7 +4817,7 @@ SELECTarrow_typeof(percentile_cont(DISTINCT arrow_cast(c, 'Decimal64(18, 2)'), 0.5))FROM t-----15 25 Decimal64(18, 2)+15.00 25.00 Decimal64(18, 2)query IRTSELECT g,@@ -4825,8 +4825,8 @@ SELECT g,arrow_typeof(percentile_cont(arrow_cast(c, 'Decimal256(54, 6)'), 0.5))FROM t GROUP BY g ORDER BY g-----1 10 Decimal256(54, 6)-2 35 Decimal256(54, 6)+1 10.000000 Decimal256(54, 6)+2 35.000000 Decimal256(54, 6)query RRTSELECT@@ -4835,7 +4835,7 @@ SELECTarrow_typeof(percentile_cont(DISTINCT arrow_cast(c, 'Decimal256(54, 6)'), 0.5))FROM t-----15 25 Decimal256(54, 6)+15.000000 25.000000 Decimal256(54, 6)statement okDROP TABLE t;@@ -4846,7 +4846,7 @@ CREATE TABLE t (c DECIMAL(50, 2)) AS VALUES (10.00), (20.00);query RTSELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY c), arrow_typeof(percentile_cont(0.5) WITHIN GROUP (ORDER BY c)) FROM t-----15 Decimal256(50, 2)+15.00 Decimal256(50, 2)statement okDROP TABLE t;@@ -4891,7 +4891,7 @@ query RTSELECT percentile_cont(0.0000001) WITHIN GROUP (ORDER BY v), arrow_typeof(percentile_cont(0.0000001) WITHIN GROUP (ORDER BY v))FROM (VALUES (arrow_cast(10.00, 'Decimal64(18, 2)')), (arrow_cast(20.00, 'Decimal64(18, 2)'))) as t (v)-----10 Decimal64(18, 2)+10.00 Decimal64(18, 2)# Decimal overflow tests to test i32 overflows for interpolation, issued for all decimalsstatement ok@@ -4903,13 +4903,13 @@ query RTSELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY v), arrow_typeof(percentile_cont(0.5) WITHIN GROUP (ORDER BY v))FROM t_percentile_series-----7005000 Decimal128(9, 2)+7005000.00 Decimal128(9, 2)query RTSELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY d), arrow_typeof(percentile_cont(0.5) WITHIN GROUP (ORDER BY d))FROM (SELECT arrow_cast(v, 'Decimal32(9, 2)') AS d FROM t_percentile_series)-----7005000 Decimal32(9, 2)+7005000.00 Decimal32(9, 2)query RTSELECT percentile_cont(0.01) WITHIN GROUP (ORDER BY d), arrow_typeof(percentile_cont(0.01) WITHIN GROUP (ORDER BY d))@@ -4951,7 +4951,7 @@ query RSELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY v)FROM (VALUES (arrow_cast(0, 'Decimal32(9, 2)')), (arrow_cast(9999999, 'Decimal32(9, 2)'))) as t (v)-----4999999.5+4999999.50query RTSELECT percentile_cont(0.00009) WITHIN GROUP (ORDER BY v),@@ -5331,7 +5331,7 @@ INSERT INTO decimals VALUES (123.0001), (124.00);query RRSELECT MIN(value), MAX(value) FROM decimals;-----123 124+123.00 124.00statement okDROP TABLE decimals;@@ -5400,7 +5400,7 @@ INSERT INTO decimals_error VALUES (123.00), (arrow_cast(124.001, 'Decimal128(10,query RRSELECT MIN(value), MAX(value) FROM decimals_error;-----123 124+123.00 124.00statement okDROP TABLE decimals_error;@@ -6573,7 +6573,7 @@ NULLquery RTselect sum(c1), arrow_typeof(sum(c1)) from d_table;-----100 Decimal128(20, 3)+100.000 Decimal128(20, 3)# aggregate sum with decimalstatement ok@@ -6582,7 +6582,7 @@ create table t (c decimal(35, 3)) as values (10), (null), (20);query RTselect sum(c), arrow_typeof(sum(c)) from t;-----30 Decimal128(38, 3)+30.000 Decimal128(38, 3)statement okdrop table t;@@ -6661,13 +6661,13 @@ B -1000.045 Decimal128(20, 3)query RTselect avg(c1), arrow_typeof(avg(c1)) from d_table-----5 Decimal128(14, 7)+5.0000000 Decimal128(14, 7)query TRTselect c2, avg(c1), arrow_typeof(avg(c1)) from d_table GROUP BY c2 ORDER BY c2-----A 110.0045 Decimal128(14, 7)-B -100.0045 Decimal128(14, 7)+A 110.0045000 Decimal128(14, 7)+B -100.0045000 Decimal128(14, 7)# aggregate_decimal_count_distinctquery I@@ -6902,18 +6902,18 @@ INSERT INTO test_decimal_table VALUES (1, 10.10, 100.1, NULL), (1, 20.20, 200.2,query IIRRRRIIRR rowsortselect c1, count(c2), avg(c2), sum(c2), min(c2), max(c2), count(c3), count(c4), sum(c4), avg(c4) from test_decimal_table group by c1-----1 2 15.15 30.3 10.1 20.2 2 0 NULL NULL-2 2 15.15 30.3 10.1 20.2 2 0 NULL NULL-3 2 10.1 20.2 10.1 10.1 1 0 NULL NULL+1 2 15.150000 30.30 10.10 20.20 2 0 NULL NULL+2 2 15.150000 30.30 10.10 20.20 2 0 NULL NULL+3 2 10.100000 20.20 10.10 10.10 1 0 NULL NULL# aggregate_decimal_with_group_by_decimalquery RIRRRRIR rowsortselect c3, count(c2), avg(c2), sum(c2), min(c2), max(c2), count(c4), sum(c4) from test_decimal_table group by c3-----100.1 2 10.1 20.2 10.1 10.1 0 NULL-200.2 1 20.2 20.2 20.2 20.2 0 NULL-700.1 2 15.15 30.3 10.1 20.2 0 NULL-NULL 1 10.1 10.1 10.1 10.1 0 NULL+100.1 2 10.100000 20.20 10.10 10.10 0 NULL+200.2 1 20.200000 20.20 20.20 20.20 0 NULL+700.1 2 15.150000 30.30 10.10 20.20 0 NULL+NULL 1 10.100000 10.10 10.10 10.10 0 NULL## Multiple distinct aggregates and dictionariesstatement ok@@ -9129,7 +9129,7 @@ create table t_decimal (c decimal(10, 4)) as values (100.00), (125.00), (175.00)query RTselect avg(distinct c), arrow_typeof(avg(distinct c)) from t_decimal;-----180 Decimal128(14, 8)+180.00000000 Decimal128(14, 8)statement okdrop table t_decimal;@@ -9149,7 +9149,7 @@ create table t_decimal256 (c decimal(50, 2)) as valuesquery RTselect avg(distinct c), arrow_typeof(avg(distinct c)) from t_decimal256;-----180 Decimal256(54, 6)+180.000000 Decimal256(54, 6)statement okdrop table t_decimal256;@@ -9293,7 +9293,7 @@ selectavg(d)from distinct_avg;-----3 Float64 37.4255 Float64 698.56005 Decimal128(14, 8) 15041.868333 Decimal256(54, 6) 4 56.52525 957.11074444 1272562.81625+3 Float64 37.4255 Float64 698.56005000 Decimal128(14, 8) 15041.868333 Decimal256(54, 6) 4 56.52525 957.11074444 1272562.816250query RRRR rowsortselect@@ -9304,11 +9304,11 @@ selectfrom distinct_avggroup by b;-----1 4.09 4222.124 0-3 NULL 2161.1901 90251.21-5 1 100.25625 45125.105-5 100.5 -49.5781 0.333333-5 44.112 -132.12 NULL+1 4.09 4222.12400000 0.000000+3 NULL 2161.19010000 90251.210000+5 1 100.25625000 45125.105000+5 100.5 -49.57810000 0.333333+5 44.112 -132.12000000 NULLquery RRRRselectdiff --git a/datafusion/sqllogictest/test_files/aggregate_skip_partial.slt b/datafusion/sqllogictest/test_files/aggregate_skip_partial.sltindex 2ed4c9921f..30c5ce4541 100644--- a/datafusion/sqllogictest/test_files/aggregate_skip_partial.slt+++ b/datafusion/sqllogictest/test_files/aggregate_skip_partial.slt@@ -742,9 +742,9 @@ FROM decimal_table CROSS JOIN tGROUP BY iORDER BY i;-----1 66-2 66-3 33+1 66.000+2 66.000+3 33.000# Config resetstatement okdiff --git a/datafusion/sqllogictest/test_files/array/array_min_max.slt b/datafusion/sqllogictest/test_files/array/array_min_max.sltindex 2e9c1035b7..108045ef4a 100644--- a/datafusion/sqllogictest/test_files/array/array_min_max.slt+++ b/datafusion/sqllogictest/test_files/array/array_min_max.slt@@ -310,7 +310,7 @@ from () as dec_list) t;-----100 300 Decimal128(20, 4) Decimal128(20, 4)+100.0000 300.0000 Decimal128(20, 4) Decimal128(20, 4)diff --git a/datafusion/sqllogictest/test_files/arrow_typeof.slt b/datafusion/sqllogictest/test_files/arrow_typeof.sltindex 17fcb7fa36..02f1911898 100644--- a/datafusion/sqllogictest/test_files/arrow_typeof.slt+++ b/datafusion/sqllogictest/test_files/arrow_typeof.slt@@ -204,7 +204,7 @@ SELECTcol_d256FROM foo;-----100 100+100.00 100.00statement okdrop table foodiff --git a/datafusion/sqllogictest/test_files/coalesce.slt b/datafusion/sqllogictest/test_files/coalesce.sltindex 79a29f7bf8..c6170e0611 100644--- a/datafusion/sqllogictest/test_files/coalesce.slt+++ b/datafusion/sqllogictest/test_files/coalesce.slt@@ -167,14 +167,14 @@ selectcoalesce(arrow_cast(2, 'Decimal128(7, 2)'), 0),arrow_typeof(coalesce(arrow_cast(2, 'Decimal128(7, 2)'), 0))-----2 Decimal128(22, 2)+2.00 Decimal128(22, 2)query RTselectcoalesce(arrow_cast(2, 'Decimal256(7, 2)'), 0),arrow_typeof(coalesce(arrow_cast(2, 'Decimal256(7, 2)'), 0));-----2 Decimal256(22, 2)+2.00 Decimal256(22, 2)# coalesce stringquery TTdiff --git a/datafusion/sqllogictest/test_files/decimal.slt b/datafusion/sqllogictest/test_files/decimal.sltindex c8475272f7..dbf30d888b 100644--- a/datafusion/sqllogictest/test_files/decimal.slt+++ b/datafusion/sqllogictest/test_files/decimal.slt@@ -19,14 +19,14 @@ query TRselect arrow_typeof(cast(1.23 as decimal(10,4))),cast(1.23 as decimal(10,4));-----Decimal128(10, 4) 1.23+Decimal128(10, 4) 1.2300query TRselect arrow_typeof(cast(cast(1.23 as decimal(10,3)) as decimal(10,4))),cast(cast(1.23 as decimal(10,3)) as decimal(10,4));-----Decimal128(10, 4) 1.23+Decimal128(10, 4) 1.2300query TR@@ -57,55 +57,55 @@ Decimal128(10, 6) Decimal128(12, 7)query R rowsortSELECT c1 from decimal_simple;-----0.00001-0.00002-0.00002-0.00003-0.00003-0.00003-0.00004-0.00004-0.00004-0.00004-0.00005-0.00005-0.00005-0.00005-0.00005+0.000010+0.000020+0.000020+0.000030+0.000030+0.000030+0.000040+0.000040+0.000040+0.000040+0.000050+0.000050+0.000050+0.000050+0.000050query R rowsortselect c1 from decimal_simple where c1 > 0.000030;-----0.00004-0.00004-0.00004-0.00004-0.00005-0.00005-0.00005-0.00005-0.00005+0.000040+0.000040+0.000040+0.000040+0.000050+0.000050+0.000050+0.000050+0.000050query RRIBR rowsortselect * from decimal_simple where c1 > c5;-----0.00002 0.000000000002 3 false 0.000019-0.00003 0.000000000003 5 true 0.000011-0.00005 0.000000000005 8 false 0.000033+0.000020 0.000000000002 3 false 0.0000190+0.000030 0.000000000003 5 true 0.0000110+0.000050 0.000000000005 8 false 0.0000330query TRselect arrow_typeof(min(c1)), min(c1) from decimal_simple where c4=false;-----Decimal128(10, 6) 0.00002+Decimal128(10, 6) 0.000020query TRselect arrow_typeof(max(c1)), max(c1) from decimal_simple where c4=false;-----Decimal128(10, 6) 0.00005+Decimal128(10, 6) 0.000050# inferred precision is 10+10@@ -113,7 +113,7 @@ Decimal128(10, 6) 0.00005query TRselect arrow_typeof(sum(c1)), sum(c1) from decimal_simple;-----Decimal128(20, 6) 0.00055+Decimal128(20, 6) 0.000550# inferred precision is original precision + 4@@ -127,14 +127,14 @@ Decimal128(14, 10) 0.0000366666query TRselect arrow_typeof(median(c1)), median(c1) from decimal_simple;-----Decimal128(10, 6) 0.00004+Decimal128(10, 6) 0.000040query RRIBR rowsortselect * from decimal_simple where c1=CAST(0.00002 as Decimal(10,8));-----0.00002 0.000000000002 2 true 0.000025-0.00002 0.000000000002 3 false 0.000019+0.000020 0.000000000002 2 true 0.0000250+0.000020 0.000000000002 3 false 0.0000190query RI rowsort@@ -158,51 +158,51 @@ select c2,c3 from decimal_simple where c1!=0.00002;query RRIBRselect * from decimal_simple where 0.00002 > c1;-----0.00001 0.000000000001 1 true 0.000014+0.000010 0.000000000001 1 true 0.0000140query RRIBR rowsortselect * from decimal_simple where c1 <= 0.00002;-----0.00001 0.000000000001 1 true 0.000014-0.00002 0.000000000002 2 true 0.000025-0.00002 0.000000000002 3 false 0.000019+0.000010 0.000000000001 1 true 0.0000140+0.000020 0.000000000002 2 true 0.0000250+0.000020 0.000000000002 3 false 0.0000190query RRIBR rowsortselect * from decimal_simple where c1 > 0.00002;-----0.00003 0.000000000003 4 true 0.000032-0.00003 0.000000000003 5 false 0.000035-0.00003 0.000000000003 5 true 0.000011-0.00004 0.000000000004 12 false 0.00004-0.00004 0.000000000004 14 true 0.00004-0.00004 0.000000000004 5 true 0.000044-0.00004 0.000000000004 8 false 0.000044-0.00005 0.000000000005 1 false 0.0001-0.00005 0.000000000005 100 true 0.000068-0.00005 0.000000000005 4 true 0.000078-0.00005 0.000000000005 8 false 0.000033-0.00005 0.000000000005 9 true 0.000052+0.000030 0.000000000003 4 true 0.0000320+0.000030 0.000000000003 5 false 0.0000350+0.000030 0.000000000003 5 true 0.0000110+0.000040 0.000000000004 12 false 0.0000400+0.000040 0.000000000004 14 true 0.0000400+0.000040 0.000000000004 5 true 0.0000440+0.000040 0.000000000004 8 false 0.0000440+0.000050 0.000000000005 1 false 0.0001000+0.000050 0.000000000005 100 true 0.0000680+0.000050 0.000000000005 4 true 0.0000780+0.000050 0.000000000005 8 false 0.0000330+0.000050 0.000000000005 9 true 0.0000520query RRIBR rowsortselect * from decimal_simple where c1 >= 0.00002;-----0.00002 0.000000000002 2 true 0.000025-0.00002 0.000000000002 3 false 0.000019-0.00003 0.000000000003 4 true 0.000032-0.00003 0.000000000003 5 false 0.000035-0.00003 0.000000000003 5 true 0.000011-0.00004 0.000000000004 12 false 0.00004-0.00004 0.000000000004 14 true 0.00004-0.00004 0.000000000004 5 true 0.000044-0.00004 0.000000000004 8 false 0.000044-0.00005 0.000000000005 1 false 0.0001-0.00005 0.000000000005 100 true 0.000068-0.00005 0.000000000005 4 true 0.000078-0.00005 0.000000000005 8 false 0.000033-0.00005 0.000000000005 9 true 0.000052+0.000020 0.000000000002 2 true 0.0000250+0.000020 0.000000000002 3 false 0.0000190+0.000030 0.000000000003 4 true 0.0000320+0.000030 0.000000000003 5 false 0.0000350+0.000030 0.000000000003 5 true 0.0000110+0.000040 0.000000000004 12 false 0.0000400+0.000040 0.000000000004 14 true 0.0000400+0.000040 0.000000000004 5 true 0.0000440+0.000040 0.000000000004 8 false 0.0000440+0.000050 0.000000000005 1 false 0.0001000+0.000050 0.000000000005 100 true 0.0000680+0.000050 0.000000000005 4 true 0.0000780+0.000050 0.000000000005 8 false 0.0000330+0.000050 0.000000000005 9 true 0.0000520query T@@ -214,21 +214,21 @@ Decimal128(27, 6)query R rowsortselect c1+1 from decimal_simple;-----1.00001-1.00002-1.00002-1.00003-1.00003-1.00003-1.00004-1.00004-1.00004-1.00004-1.00005-1.00005-1.00005-1.00005-1.00005+1.000010+1.000020+1.000020+1.000030+1.000030+1.000030+1.000040+1.000040+1.000040+1.000040+1.000050+1.000050+1.000050+1.000050+1.000050# array decimal(10,6) + array decimal(12,7) => decimal(13,7)@@ -241,21 +241,21 @@ Decimal128(13, 7)query R rowsortselect c1+c5 from decimal_simple;-----0.000024-0.000039-0.000041-0.000045-0.000062-0.000065-0.00008-0.00008-0.000083-0.000084-0.000084-0.000102-0.000118-0.000128-0.00015+0.0000240+0.0000390+0.0000410+0.0000450+0.0000620+0.0000650+0.0000800+0.0000800+0.0000830+0.0000840+0.0000840+0.0001020+0.0001180+0.0001280+0.0001500query T@@ -267,21 +267,21 @@ Decimal128(27, 6)query R rowsortselect c1-1 from decimal_simple;------0.99995--0.99995--0.99995--0.99995--0.99995--0.99996--0.99996--0.99996--0.99996--0.99997--0.99997--0.99997--0.99998--0.99998--0.99999+-0.999950+-0.999950+-0.999950+-0.999950+-0.999950+-0.999960+-0.999960+-0.999960+-0.999960+-0.999970+-0.999970+-0.999970+-0.999980+-0.999980+-0.999990query T@@ -293,21 +293,21 @@ Decimal128(13, 7)query R rowsortselect c1-c5 from decimal_simple;------0.000002--0.000002--0.000004--0.000004--0.000004--0.000005--0.000005--0.000018--0.000028--0.00005-0-0-0.000001-0.000017-0.000019+-0.0000020+-0.0000020+-0.0000040+-0.0000040+-0.0000040+-0.0000050+-0.0000050+-0.0000180+-0.0000280+-0.0000500+0.0000000+0.0000000+0.0000010+0.0000170+0.0000190query T@@ -319,21 +319,21 @@ Decimal128(31, 6)query R rowsortselect c1*20 from decimal_simple;-----0.0002-0.0004-0.0004-0.0006-0.0006-0.0006-0.0008-0.0008-0.0008-0.0008-0.001-0.001-0.001-0.001-0.001+0.000200+0.000400+0.000400+0.000600+0.000600+0.000600+0.000800+0.000800+0.000800+0.000800+0.001000+0.001000+0.001000+0.001000+0.001000query T@@ -345,21 +345,21 @@ Decimal128(23, 13)query R rowsortselect c1*c5 from decimal_simple;-----0.00000000014-0.00000000033-0.00000000038-0.0000000005-0.00000000096-0.00000000105-0.0000000016-0.0000000016-0.00000000165-0.00000000176-0.00000000176-0.0000000026-0.0000000034-0.0000000039-0.000000005+0.0000000001400+0.0000000003300+0.0000000003800+0.0000000005000+0.0000000009600+0.0000000010500+0.0000000016000+0.0000000016000+0.0000000016500+0.0000000017600+0.0000000017600+0.0000000026000+0.0000000034000+0.0000000039000+0.0000000050000query T@@ -371,21 +371,21 @@ Decimal128(19, 10)query R rowsortselect c1/cast(0.00001 as decimal(5,5)) from decimal_simple;-----1-2-2-3-3-3-4-4-4-4-5-5-5-5-5+1.0000000000+2.0000000000+2.0000000000+3.0000000000+3.0000000000+3.0000000000+4.0000000000+4.0000000000+4.0000000000+4.0000000000+5.0000000000+5.0000000000+5.0000000000+5.0000000000+5.0000000000query T@@ -397,18 +397,18 @@ Decimal128(21, 10)query R rowsortselect c1/c5 from decimal_simple;-----0.5-0.641025641+0.5000000000+0.64102564100.71428571420.7352941176-0.8+0.80000000000.8571428571-0.909090909-0.909090909-0.9375+0.9090909090+0.9090909090+0.93750000000.9615384615-1-1+1.0000000000+1.00000000001.05263157891.51515151512.7272727272@@ -423,21 +423,21 @@ Decimal128(7, 7)query R rowsortselect c5%cast(0.00001 as decimal(5,5)) from decimal_simple;-----0-0-0-0.000001-0.000002-0.000002-0.000003-0.000004-0.000004-0.000004-0.000005-0.000005-0.000008-0.000008-0.000009+0.0000000+0.0000000+0.0000000+0.0000010+0.0000020+0.0000020+0.0000030+0.0000040+0.0000040+0.0000040+0.0000050+0.0000050+0.0000080+0.0000080+0.0000090query T@@ -449,21 +449,21 @@ Decimal128(11, 7)query R rowsortselect c1%c5 from decimal_simple;-----0-0-0.000001-0.000008-0.00001-0.000017-0.00002-0.00003-0.00003-0.00004-0.00004-0.00005-0.00005-0.00005-0.00005+0.0000000+0.0000000+0.0000010+0.0000080+0.0000100+0.0000170+0.0000200+0.0000300+0.0000300+0.0000400+0.0000400+0.0000500+0.0000500+0.0000500+0.0000500query T@@ -475,104 +475,104 @@ Decimal128(10, 6)query R rowsortSELECT abs(c1) from decimal_simple;-----0.00001-0.00002-0.00002-0.00003-0.00003-0.00003-0.00004-0.00004-0.00004-0.00004-0.00005-0.00005-0.00005-0.00005-0.00005+0.000010+0.000020+0.000020+0.000030+0.000030+0.000030+0.000040+0.000040+0.000040+0.000040+0.000050+0.000050+0.000050+0.000050+0.000050query RRIBRselect * from decimal_simple where c1 >= 0.00004 order by c1;-----0.00004 0.000000000004 5 true 0.000044-0.00004 0.000000000004 12 false 0.00004-0.00004 0.000000000004 14 true 0.00004-0.00004 0.000000000004 8 false 0.000044-0.00005 0.000000000005 9 true 0.000052-0.00005 0.000000000005 4 true 0.000078-0.00005 0.000000000005 8 false 0.000033-0.00005 0.000000000005 100 true 0.000068-0.00005 0.000000000005 1 false 0.0001+0.000040 0.000000000004 5 true 0.0000440+0.000040 0.000000000004 12 false 0.0000400+0.000040 0.000000000004 14 true 0.0000400+0.000040 0.000000000004 8 false 0.0000440+0.000050 0.000000000005 9 true 0.0000520+0.000050 0.000000000005 4 true 0.0000780+0.000050 0.000000000005 8 false 0.0000330+0.000050 0.000000000005 100 true 0.0000680+0.000050 0.000000000005 1 false 0.0001000query RRIBRselect * from decimal_simple where c1 >= 0.00004 order by c1, c3 limit 10;-----0.00004 0.000000000004 5 true 0.000044-0.00004 0.000000000004 8 false 0.000044-0.00004 0.000000000004 12 false 0.00004-0.00004 0.000000000004 14 true 0.00004-0.00005 0.000000000005 1 false 0.0001-0.00005 0.000000000005 4 true 0.000078-0.00005 0.000000000005 8 false 0.000033-0.00005 0.000000000005 9 true 0.000052-0.00005 0.000000000005 100 true 0.000068+0.000040 0.000000000004 5 true 0.0000440+0.000040 0.000000000004 8 false 0.0000440+0.000040 0.000000000004 12 false 0.0000400+0.000040 0.000000000004 14 true 0.0000400+0.000050 0.000000000005 1 false 0.0001000+0.000050 0.000000000005 4 true 0.0000780+0.000050 0.000000000005 8 false 0.0000330+0.000050 0.000000000005 9 true 0.0000520+0.000050 0.000000000005 100 true 0.0000680query RRIBRselect * from decimal_simple where c1 >= 0.00004 order by c1, c3 limit 5;-----0.00004 0.000000000004 5 true 0.000044-0.00004 0.000000000004 8 false 0.000044-0.00004 0.000000000004 12 false 0.00004-0.00004 0.000000000004 14 true 0.00004-0.00005 0.000000000005 1 false 0.0001+0.000040 0.000000000004 5 true 0.0000440+0.000040 0.000000000004 8 false 0.0000440+0.000040 0.000000000004 12 false 0.0000400+0.000040 0.000000000004 14 true 0.0000400+0.000050 0.000000000005 1 false 0.0001000query RRIBRselect * from decimal_simple where c1 >= 0.00004 order by c1 desc;-----0.00005 0.000000000005 9 true 0.000052-0.00005 0.000000000005 4 true 0.000078-0.00005 0.000000000005 8 false 0.000033-0.00005 0.000000000005 100 true 0.000068-0.00005 0.000000000005 1 false 0.0001-0.00004 0.000000000004 5 true 0.000044-0.00004 0.000000000004 12 false 0.00004-0.00004 0.000000000004 14 true 0.00004-0.00004 0.000000000004 8 false 0.000044+0.000050 0.000000000005 9 true 0.0000520+0.000050 0.000000000005 4 true 0.0000780+0.000050 0.000000000005 8 false 0.0000330+0.000050 0.000000000005 100 true 0.0000680+0.000050 0.000000000005 1 false 0.0001000+0.000040 0.000000000004 5 true 0.0000440+0.000040 0.000000000004 12 false 0.0000400+0.000040 0.000000000004 14 true 0.0000400+0.000040 0.000000000004 8 false 0.0000440query RRIBRselect * from decimal_simple where c1 < 0.00003 order by c1 desc,c4;-----0.00002 0.000000000002 3 false 0.000019-0.00002 0.000000000002 2 true 0.000025-0.00001 0.000000000001 1 true 0.000014+0.000020 0.000000000002 3 false 0.0000190+0.000020 0.000000000002 2 true 0.0000250+0.000010 0.000000000001 1 true 0.0000140query IRselect count(*),c1 from decimal_simple group by c1 order by c1;-----1 0.00001-2 0.00002-3 0.00003-4 0.00004-5 0.00005+1 0.000010+2 0.000020+3 0.000030+4 0.000040+5 0.000050query IRBselect count(*),c1,c4 from decimal_simple group by c1,c4 order by c1,c4;-----1 0.00001 true-1 0.00002 false-1 0.00002 true-1 0.00003 false-2 0.00003 true-2 0.00004 false-2 0.00004 true-2 0.00005 false-3 0.00005 true+1 0.000010 true+1 0.000020 false+1 0.000020 true+1 0.000030 false+2 0.000030 true+2 0.000040 false+2 0.000040 true+2 0.000050 false+3 0.000050 truequery TR@@ -612,12 +612,12 @@ insert into foo VALUES (1, 5);query Rselect a / b from foo;-----0.2+0.200000000000000000000000query Rselect AVG(column1) from values (arrow_cast(123, 'Decimal256(5,2)'));-----123+123.000000statement okCREATE EXTERNAL TABLE decimal256_simple (@@ -639,41 +639,41 @@ Decimal256(50, 6) Decimal256(52, 7)query R rowsortSELECT c1 from decimal256_simple;-----0.00001-0.00002-0.00002-0.00003-0.00003-0.00003-0.00004-0.00004-0.00004-0.00004-0.00005-0.00005-0.00005-0.00005-0.00005+0.000010+0.000020+0.000020+0.000030+0.000030+0.000030+0.000040+0.000040+0.000040+0.000040+0.000050+0.000050+0.000050+0.000050+0.000050query R rowsortselect c1 from decimal256_simple where c1 > 0.000030;-----0.00004-0.00004-0.00004-0.00004-0.00005-0.00005-0.00005-0.00005-0.00005+0.000040+0.000040+0.000040+0.000040+0.000050+0.000050+0.000050+0.000050+0.000050query RRIBR rowsortselect * from decimal256_simple where c1 > c5;-----0.00002 0.000000000002 3 false 0.000019-0.00003 0.000000000003 5 true 0.000011-0.00005 0.000000000005 8 false 0.000033+0.000020 0.000000000002 3 false 0.0000190+0.000030 0.000000000003 5 true 0.0000110+0.000050 0.000000000005 8 false 0.0000330query TRselect arrow_typeof(avg(c1)), avg(c1) from decimal256_simple;@@ -683,31 +683,31 @@ Decimal256(54, 10) 0.0000366666query TRselect arrow_typeof(min(c1)), min(c1) from decimal256_simple where c4=false;-----Decimal256(50, 6) 0.00002+Decimal256(50, 6) 0.000020query TRselect arrow_typeof(max(c1)), max(c1) from decimal256_simple where c4=false;-----Decimal256(50, 6) 0.00005+Decimal256(50, 6) 0.000050query TRselect arrow_typeof(sum(c1)), sum(c1) from decimal256_simple;-----Decimal256(60, 6) 0.00055+Decimal256(60, 6) 0.000550query TRselect arrow_typeof(median(c1)), median(c1) from decimal256_simple;-----Decimal256(50, 6) 0.00004+Decimal256(50, 6) 0.000040query IRselect count(*),c1 from decimal256_simple group by c1 order by c1;-----1 0.00001-2 0.00002-3 0.00003-4 0.00004-5 0.00005+1 0.000010+2 0.000020+3 0.000030+4 0.000040+5 0.000050query Iselect count(DISTINCT cast(c1 AS DECIMAL(42, 4))) from decimal256_simple;@@ -735,7 +735,7 @@ SELECTcast(cast('0' as decimal(3,0)) as decimal(2,0)),cast(cast('5.20' as decimal(4,2)) as decimal(3,2))-----0 5.2+0 5.20query RRSELECT@@ -763,7 +763,7 @@ SELECTarrow_cast(1.23,'Decimal128(3,2)') / arrow_cast(123, 'UInt64') as divison_uint,arrow_cast(1.23,'Decimal128(3,2)') / arrow_cast(123, 'Int64') as divison_int-----0.01 0.01+0.010000 0.010000query TRwith tt as (@@ -1198,20 +1198,20 @@ NULL Float64query RR rowsortSELECT distinct c1*100000, power(c1*100000, 2) from decimal_simple;-----1 1-2 4-3 9-4 16-5 25+1.000000 1+2.000000 4+3.000000 9+4.000000 16+5.000000 25query RR rowsortSELECT distinct c1*100000, power(c1*100000, 2.0) from decimal_simple;-----1 1-2 4-3 9-4 16-5 25+1.000000 1+2.000000 4+3.000000 9+4.000000 16+5.000000 25# Set parse_float_as_decimal to false to test float parsingstatement ok@@ -1305,7 +1305,7 @@ from (from generate_series(1, 21476)) t;-----99999 Decimal32(9, 4)+99999.0000 Decimal32(9, 4)# 92235 * 99999999999999 ~= 9.22e18 > i64::MAXquery RT@@ -1315,7 +1315,7 @@ from (from generate_series(1, 92235)) t;-----99999999999999 Decimal64(18, 4)+99999999999999.0000 Decimal64(18, 4)# 21476 * (10^34 - 1) ~= 2.15e38 > i128::MAXquery RT@@ -1325,7 +1325,7 @@ from (from generate_series(1, 21476)) t;-----9999999999999999999999999999999999 Decimal128(38, 4)+9999999999999999999999999999999999.0000 Decimal128(38, 4)# Regression: `avg(DISTINCT ...)` must widen its intermediate sum the same way.# The second distinct aggregate keeps `single_distinct_to_group_by` from@@ -1339,7 +1339,7 @@ from (from generate_series(1, 65536) t(v)) t;-----32768.5 Decimal64(13, 4) 32768.5+32768.5000 Decimal64(13, 4) 32768.5# TPC-DS `store_returns.sr_return_amt` is Decimal32(7, 2). Its average needs# Decimal(11, 6), which requires Decimal64 rather than a clamped Decimal32(9, 6).@@ -1351,7 +1351,7 @@ from ((arrow_cast(2.00, 'Decimal32(7, 2)'))) t(d);-----1.5 Decimal64(11, 6)+1.500000 Decimal64(11, 6)# GROUP BY selects the groups accumulator, which must produce the same widened# Decimal64 output type for each group.@@ -1367,5 +1367,11 @@ from (group by gorder by g;-----1 1.5 Decimal64(11, 6)-2 3.5 Decimal64(11, 6)+1 1.500000 Decimal64(11, 6)+2 3.500000 Decimal64(11, 6)++# Decimals should not lose precision with trailing zeroes+query RB+select arrow_cast('1.2300', 'Decimal32(9, 4)'), arrow_cast(arrow_cast('1.2300', 'Decimal32(9, 4)'), 'Utf8') == '1.2300';+----+1.2300 truediff --git a/datafusion/sqllogictest/test_files/group_by.slt b/datafusion/sqllogictest/test_files/group_by.sltindex 38d1b78214..08d2ee509f 100644--- a/datafusion/sqllogictest/test_files/group_by.slt+++ b/datafusion/sqllogictest/test_files/group_by.slt@@ -5592,7 +5592,7 @@ select a, b, count(*) from t group by a, b order by a, b;----1 123.45 21 NULL 1-2 678.9 3+2 678.90 32 1011.12 23 1314.15 2NULL 123.45 2@@ -5774,9 +5774,9 @@ create table decimal256_multi_group (k int, d decimal(50, 2)) as valuesquery IRIselect k, d, count(*) from decimal256_multi_group group by k, d order by k, d;-----1 100 2-1 250 1-2 100 1+1 100.00 2+1 250.00 1+2 100.00 12 NULL 1statement okdiff --git a/datafusion/sqllogictest/test_files/joins.slt b/datafusion/sqllogictest/test_files/joins.sltindex 93e9d1c03c..fe1e09dc9d 100644--- a/datafusion/sqllogictest/test_files/joins.slt+++ b/datafusion/sqllogictest/test_files/joins.slt@@ -2718,7 +2718,7 @@ query DDRTDDRT rowsortselect * from hashjoin_datatype_table_t1 t1 join hashjoin_datatype_table_t2 t2 on t1.c1 = t2.c1----1970-01-02 1970-01-02T00:00:00 1.23 abc 1970-01-02 1970-01-02T00:00:00 -123.12 abc-1970-01-04 NULL -123.12 jkl 1970-01-04 NULL 789 qwe+1970-01-04 NULL -123.12 jkl 1970-01-04 NULL 789.00 qwe# explain hash_join_with_date64@@ -2737,9 +2737,9 @@ query DDRTDDRT rowsortselect * from hashjoin_datatype_table_t1 t1 left join hashjoin_datatype_table_t2 t2 on t1.c2 = t2.c2----1970-01-02 1970-01-02T00:00:00 1.23 abc 1970-01-02 1970-01-02T00:00:00 -123.12 abc-1970-01-03 1970-01-03T00:00:00 456 def NULL NULL NULL NULL+1970-01-03 1970-01-03T00:00:00 456.00 def NULL NULL NULL NULL1970-01-04 NULL -123.12 jkl NULL NULL NULL NULL-NULL 1970-01-04T00:00:00 789 ghi NULL 1970-01-04T00:00:00 0 qwerty+NULL 1970-01-04T00:00:00 789.00 ghi NULL 1970-01-04T00:00:00 0.00 qwerty# explain hash_join_with_decimal@@ -2758,9 +2758,9 @@ query DDRTDDRT rowsortselect * from hashjoin_datatype_table_t1 t1 right join hashjoin_datatype_table_t1 t2 on t1.c3 = t2.c3----1970-01-02 1970-01-02T00:00:00 1.23 abc 1970-01-02 1970-01-02T00:00:00 1.23 abc-1970-01-03 1970-01-03T00:00:00 456 def 1970-01-03 1970-01-03T00:00:00 456 def+1970-01-03 1970-01-03T00:00:00 456.00 def 1970-01-03 1970-01-03T00:00:00 456.00 def1970-01-04 NULL -123.12 jkl 1970-01-04 NULL -123.12 jkl-NULL 1970-01-04T00:00:00 789 ghi NULL 1970-01-04T00:00:00 789 ghi+NULL 1970-01-04T00:00:00 789.00 ghi NULL 1970-01-04T00:00:00 789.00 ghi# explain hash_join_with_dictionaryquery TT@@ -2825,7 +2825,7 @@ query DDRTDDRT rowsortselect * from hashjoin_datatype_table_t1 t1 join hashjoin_datatype_table_t2 t2 on t1.c1 = t2.c1----1970-01-02 1970-01-02T00:00:00 1.23 abc 1970-01-02 1970-01-02T00:00:00 -123.12 abc-1970-01-04 NULL -123.12 jkl 1970-01-04 NULL 789 qwe+1970-01-04 NULL -123.12 jkl 1970-01-04 NULL 789.00 qwe# explain sort_merge_join_on_decimal right join on data type (Decimal)query TT@@ -2853,9 +2853,9 @@ query DDRTDDRT rowsortselect * from hashjoin_datatype_table_t1 t1 right join hashjoin_datatype_table_t2 t2 on t1.c3 = t2.c3----1970-01-04 NULL -123.12 jkl 1970-01-02 1970-01-02T00:00:00 -123.12 abc-NULL 1970-01-04T00:00:00 789 ghi 1970-01-04 NULL 789 qwe-NULL NULL NULL NULL NULL 1970-01-04T00:00:00 0 qwerty-NULL NULL NULL NULL NULL NULL 100000 abcdefg+NULL 1970-01-04T00:00:00 789.00 ghi 1970-01-04 NULL 789.00 qwe+NULL NULL NULL NULL NULL 1970-01-04T00:00:00 0.00 qwerty+NULL NULL NULL NULL NULL NULL 100000.00 abcdefg# Pushing the projection below the sort merge join must not drop a column that# the join filter still needs (t2.c2 here). Instead the join applies the@@ -2883,9 +2883,9 @@ query DDR rowsortselect t1.c1, t2.c1, t2.c3 from hashjoin_datatype_table_t1 t1 right join hashjoin_datatype_table_t2 t2 on t1.c1 = t2.c1 and t1.c2 < t2.c2----NULL 1970-01-02 -123.12-NULL 1970-01-04 789-NULL NULL 0-NULL NULL 100000+NULL 1970-01-04 789.00+NULL NULL 0.00+NULL NULL 100000.00# Regression test: projection optimization through SortMergeJoinExec must keep# JoinFilter columns available when the output projection does not select them.diff --git a/datafusion/sqllogictest/test_files/math.slt b/datafusion/sqllogictest/test_files/math.sltindex b6bf51dd47..1eaf4c8f25 100644--- a/datafusion/sqllogictest/test_files/math.slt+++ b/datafusion/sqllogictest/test_files/math.slt@@ -148,9 +148,9 @@ SELECTround(arrow_cast(column1, 'Decimal256(40,2)'), column2)FROM (VALUES ('125.55', 1), ('-125.55', 0), ('125.55', -1), (NULL, 1)) AS t(column1, column2);-----125.6 125.6 125.6 125.6--126 -126 -126 -126-130 130 130 130+125.60 125.60 125.60 125.60+-126.00 -126.00 -126.00 -126.00+130.00 130.00 130.00 130.00NULL NULL NULL NULL# Float arrays with scalar and per-row decimal places@@ -826,9 +826,9 @@ NULLquery RSELECT c1*0 FROM test_nullable_decimal WHERE c1 IS NOT NULL;-----0-0-0+0.00+0.00+0.00query error DataFusion error: Arrow error: Divide by zero errorSELECT c1/0 FROM test_nullable_decimal WHERE c1 IS NOT NULL;@@ -851,7 +851,7 @@ Decimal128(10, 2) Decimal128(38, 10) Decimal256(40, 2) Decimal256(76, 10)query RRRR rowsortSELECT abs(c1), abs(c2), abs(c3), abs(c4) FROM test_nullable_decimal-----0 0 0 0+0.00 0.0000000000 0.00 0.000000000099999999.99 9999999999999999999999999999.9999999999 99999999999999999999999999999999999999.99 999999999999999999999999999999999999999999999999999999999999999999.999999999999999999.99 9999999999999999999999999999.9999999999 99999999999999999999999999999999999999.99 999999999999999999999999999999999999999999999999999999999999999999.9999999999NULL NULL NULL NULL@@ -979,7 +979,7 @@ select gcd(15.3::decimal(38, 1), 2.9::decimal(38, 1)), arrow_typeof(gcd(15.3::dequery RTselect gcd(15::decimal(30, 2), 3::decimal(38, 5)), arrow_typeof(gcd(15::decimal(30, 2), 3::decimal(38, 5)));-----3 Decimal128(38, 5)+3.00000 Decimal128(38, 5)## lcm@@ -1041,7 +1041,7 @@ select lcm(2, 3::decimal(38, 0)), arrow_typeof(lcm(2, 3::decimal(38, 0)));query RTselect lcm(2::decimal(30, 2), 3::decimal(38, 5)), arrow_typeof(lcm(2::decimal(30, 2), 3::decimal(38, 5)));-----6 Decimal128(38, 5)+6.00000 Decimal128(38, 5)## pow/powerdiff --git a/datafusion/sqllogictest/test_files/options.slt b/datafusion/sqllogictest/test_files/options.sltindex 00d7664779..c01358b4f6 100644--- a/datafusion/sqllogictest/test_files/options.slt+++ b/datafusion/sqllogictest/test_files/options.slt@@ -139,7 +139,7 @@ Int64 Int64 Decimal128(19, 0) Int64 UInt64 UInt64 Decimal128(20, 0)query RRRRselect .0 as c1, 0. as c2, 0000. as c3, 00000.00 as c4-----0 0 0 0+0.0 0 0 0.00query TTTTselect arrow_typeof(.0) as c1, arrow_typeof(0.) as c2, arrow_typeof(0000.) as c3, arrow_typeof(00000.00) as c4@@ -209,13 +209,13 @@ query RTselect 123456789.0123456789012345678901234567890,arrow_typeof(123456789.0123456789012345678901234567890)-----123456789.012345678901234567890123456789 Decimal256(40, 31)+123456789.0123456789012345678901234567890 Decimal256(40, 31)query RTselect -123456789.0123456789012345678901234567890,arrow_typeof(-123456789.0123456789012345678901234567890)------123456789.012345678901234567890123456789 Decimal256(40, 31)+-123456789.0123456789012345678901234567890 Decimal256(40, 31)# max precision and scale of Decimal256query RTRT@@ -277,7 +277,7 @@ query RTRTselect 1e40 + 1e40, arrow_typeof(1e40 + 1e40),1e-40 + -1e-40, arrow_typeof(1e-40 + -1e-40)-----20000000000000000000000000000000000000000 Decimal128(2, -40) 0 Decimal256(41, 40)+20000000000000000000000000000000000000000 Decimal128(2, -40) 0.0000000000000000000000000000000000000000 Decimal256(41, 40)# Restore option to default valuestatement okdiff --git a/datafusion/sqllogictest/test_files/pg_compat/pg_compat_simple.slt b/datafusion/sqllogictest/test_files/pg_compat/pg_compat_simple.sltindex 4453aa1489..fbca0e12d3 100644--- a/datafusion/sqllogictest/test_files/pg_compat/pg_compat_simple.slt+++ b/datafusion/sqllogictest/test_files/pg_compat/pg_compat_simple.slt@@ -73,15 +73,17 @@ OPTIONS ('format.has_header' 'true');-query RRRRR+# float formats to 12 points, numeric to explicit precision+query RRRRRRSELECTabs(-1.1) as abs,- exp(2.0) as exp,+ cast(exp(2.0) as double precision) as exp_double,+ cast(exp(2.0) as numeric(38,10)) as exp_numeric,sin(3.0) as sin,cos(4.0) as cos,tan(5.0) as tan;-----1.1 7.389056098931 0.14112000806 -0.653643620864 -3.380515006247+1.1 7.389056098931 7.3890560989 0.14112000806 -0.653643620864 -3.380515006247query I@@ -316,20 +318,31 @@ ORDER BY c5 ASC, c4 DESC, c10;2143473091 -14704 4602675983996931623+# floats are numerics by default in postgres+onlyif postgresquery IRII rowsortSELECT * FROM(VALUES (1,2.0,-3,1+1),(10,20.0,-30,2+2))AS tbl(int_col, float_col, negative_col, summation);-----1 2 -3 2-10 20 -30 4+1 2.0 -3 2+10 20.0 -30 4+# explicit float and numeric behaviour+query IRRII rowsort+SELECT * FROM+(VALUES (1,2.0::double precision,2.0::numeric(4,1),-3,1+1),(10,20.0::double precision,20.0::numeric(4,1),-30,2+2))+AS tbl(int_col, float_col, numeric_col, negative_col, summation);+----+1 2 2.0 -3 2+10 20 20.0 -30 4+# note: cast avg result since Postgres avg returns numeric by defaultquery IIRIIIIIISELECTcount(*) AS count_all,count(c3) AS count_c3,- avg(c3) AS avg,+ cast(avg(c3) as double precision) AS avg_double,sum(c3) AS sum,max(c3) AS max,min(c3) AS min,@@ -340,12 +353,11 @@ FROM aggregate_test_100_by_sql;----100 100 7.81 781 125 -117 0 -1 -61-query IIRIIIIIIselectc2,sum(c3) sum_c3,- avg(c3) avg_c3,+ cast(avg(c3) as double precision) AS avg_c3,max(c3) max_c3,min(c3) min_c3,count(c3) count_c3,diff --git a/datafusion/sqllogictest/test_files/pg_compat/pg_compat_types.slt b/datafusion/sqllogictest/test_files/pg_compat/pg_compat_types.sltindex 7e315a448b..8339fb4fab 100644--- a/datafusion/sqllogictest/test_files/pg_compat/pg_compat_types.slt+++ b/datafusion/sqllogictest/test_files/pg_compat/pg_compat_types.slt@@ -99,7 +99,7 @@ select 1.0::DOUBLE, 1.023::DOUBLE, 'NaN'::DOUBLE,'+Inf'::DOUBLE,'-Inf'::DOUBLEquery RRRselect 1.0::DECIMAL(5,3) as one, 2.023::DECIMAL(5,3) as two, 3.023::DECIMAL(5,2) as three-----1 2.023 3.02+1.000 2.023 3.02query Dselect '2018-01-01'::DATEdiff --git a/datafusion/sqllogictest/test_files/pg_compat/pg_compat_window.slt b/datafusion/sqllogictest/test_files/pg_compat/pg_compat_window.sltindex f967d79a6d..a013cc402b 100644--- a/datafusion/sqllogictest/test_files/pg_compat/pg_compat_window.slt+++ b/datafusion/sqllogictest/test_files/pg_compat/pg_compat_window.slt@@ -305,7 +305,7 @@ query IIRIIIIIISELECTrow_number() OVER () AS row_number,count(c3) OVER () AS count_c3,- avg(c3) OVER () AS avg,+ cast(avg(c3) OVER () as double precision) AS avg,sum(c3) OVER () AS sum,max(c3) OVER () AS max,min(c3) OVER () AS min,@@ -694,7 +694,7 @@ SELECTc9,row_number() OVER (ORDER BY c2, c9) AS row_number,count(c3) OVER (ORDER BY c9) AS count_c3,- avg(c3) OVER (ORDER BY c2) AS avg_c3_by_c2,+ cast(avg(c3) OVER (ORDER BY c2) as double precision) AS avg_c3_by_c2,sum(c3) OVER (ORDER BY c2) AS sum_c3_by_c2,max(c3) OVER (ORDER BY c2) AS max_c3_by_c2,min(c3) OVER (ORDER BY c2) AS min_c3_by_c2,@@ -811,7 +811,7 @@ SELECTc9,row_number() OVER (PARTITION BY c2, c9) AS row_number,count(c3) OVER (PARTITION BY c2) AS count_c3,- avg(c3) OVER (PARTITION BY c2) AS avg_c3_by_c2,+ cast(avg(c3) OVER (PARTITION BY c2) as double precision) AS avg_c3_by_c2,sum(c3) OVER (PARTITION BY c2) AS sum_c3_by_c2,max(c3) OVER (PARTITION BY c2) AS max_c3_by_c2,min(c3) OVER (PARTITION BY c2) AS min_c3_by_c2,@@ -928,7 +928,7 @@ SELECTc9,row_number() OVER (PARTITION BY c2 ORDER BY c9) AS row_number,count(c3) OVER (PARTITION BY c2 ORDER BY c9) AS count_c3,- avg(c3) OVER (PARTITION BY c2 ORDER BY c9) AS avg_c3_by_c2,+ cast(avg(c3) OVER (PARTITION BY c2 ORDER BY c9) as double precision) AS avg_c3_by_c2,sum(c3) OVER (PARTITION BY c2 ORDER BY c9) AS sum_c3_by_c2,max(c3) OVER (PARTITION BY c2 ORDER BY c9) AS max_c3_by_c2,min(c3) OVER (PARTITION BY c2 ORDER BY c9) AS min_c3_by_c2,diff --git a/datafusion/sqllogictest/test_files/predicates.slt b/datafusion/sqllogictest/test_files/predicates.sltindex b4482a3af1..9e28d1fb08 100644--- a/datafusion/sqllogictest/test_files/predicates.slt+++ b/datafusion/sqllogictest/test_files/predicates.slt@@ -874,7 +874,7 @@ OR)GROUP BY p_partkey;-----63700 13309.6 0.1 1+63700 13309.60 0.100000 1query TTdiff --git a/datafusion/sqllogictest/test_files/qualify.slt b/datafusion/sqllogictest/test_files/qualify.sltindex b70f078327..ca4775ef12 100644--- a/datafusion/sqllogictest/test_files/qualify.slt+++ b/datafusion/sqllogictest/test_files/qualify.slt@@ -92,9 +92,9 @@ FROM usersQUALIFY prev_salary IS NOT NULL AND salary > prev_salaryORDER BY dept, id;-----2 Bob 60000 50000-8 Henry 62000 52000-7 Grace 75000 65000+2 Bob 60000.00 50000.00+8 Henry 62000.00 52000.00+7 Grace 75000.00 65000.00# QUALIFY with LEAD functionquery ITRR@@ -103,9 +103,9 @@ FROM usersQUALIFY next_salary IS NOT NULL AND salary < next_salaryORDER BY dept, id;-----1 Alice 50000 60000-6 Frank 52000 62000-5 Eve 65000 75000+1 Alice 50000.00 60000.00+6 Frank 52000.00 62000.00+5 Eve 65000.00 75000.00# QUALIFY with NTILEquery ITI@@ -164,8 +164,8 @@ FROM usersQUALIFY rn = 1 AND salary > 60000ORDER BY dept, id;-----8 Henry 62000 1-7 Grace 75000 1+8 Henry 62000.00 1+7 Grace 75000.00 1# QUALIFY with string functionsquery ITI@@ -200,9 +200,9 @@ GROUP BY dept, salaryHAVING SUM(salary) > 20000QUALIFY r > 60000-----Marketing 70000-Marketing 70000-Marketing 70000+Marketing 70000.000000+Marketing 70000.000000+Marketing 70000.000000# QUALIFY with aggregate function reference from projectionquery TR@@ -212,7 +212,7 @@ GROUP BY deptQUALIFY RANK() OVER (ORDER BY dept DESC) = 1 AND s > 1000ORDER BY dept;-----Marketing 210000+Marketing 210000.00# QUALIFY with aggregate functionquery T@@ -232,7 +232,7 @@ GROUP BY deptQUALIFY RANK() OVER (ORDER BY SUM(salary) DESC) = 1ORDER BY dept;-----Engineering 279000+Engineering 279000.00# QUALIFY with aggregate function reference from projection within window functionquery TR@@ -242,7 +242,7 @@ GROUP BY deptQUALIFY RANK() OVER (ORDER BY s DESC) = 1ORDER BY dept;-----Engineering 279000+Engineering 279000.00# Error: QUALIFY without window functionsquery errordiff --git a/datafusion/sqllogictest/test_files/run_end_encoded.slt b/datafusion/sqllogictest/test_files/run_end_encoded.sltindex 094f6ede1b..cbac587b17 100644--- a/datafusion/sqllogictest/test_files/run_end_encoded.slt+++ b/datafusion/sqllogictest/test_files/run_end_encoded.slt@@ -63,10 +63,10 @@ SELECTarrow_cast(arrow_cast(temperature, 'Decimal128(10, 2)'), 'RunEndEncoded("run_ends": non-null Int32, "values": Decimal128(10, 2))') + 1 AS t_dec_plus_oneFROM sensor_readings;-----21 21-23 23-24 24-25 25+21 21.00+23 23.00+24 24.00+25 25.00# Regex / LIKE match against an REE column whose values are themselves Dictionary-encodedquery BB rowsortdiff --git a/datafusion/sqllogictest/test_files/scalar.slt b/datafusion/sqllogictest/test_files/scalar.sltindex 52de4f9d4c..3e7c81b827 100644--- a/datafusion/sqllogictest/test_files/scalar.slt+++ b/datafusion/sqllogictest/test_files/scalar.slt@@ -1107,7 +1107,7 @@ query TRselect arrow_typeof(round(val, dp)), round(val, dp)from (values (cast('999.9' as decimal(4,1)), 0)) as t(val, dp);-----Decimal128(5, 1) 1000+Decimal128(5, 1) 1000.0# round decimal at max precision now works (scale reduction handles overflow)query TR@@ -1128,7 +1128,7 @@ select arrow_typeof(round(cast(500 as decimal(10,-2)), -3)),round(cast(400 as decimal(10,-2)), -3),round(cast(-500 as decimal(10,-2)), -3);-----Decimal128(10, -3) 1000 0 -1000+Decimal128(10, -3) 1000 0000 -1000# round decimal with negative scale and carry-overquery TR@@ -1361,7 +1361,7 @@ from small_floats;query RTselect trunc(arrow_cast(3.1415, 'Decimal128(10,4)')), arrow_typeof(trunc(arrow_cast(3.1415, 'Decimal128(10,4)')));-----3 Decimal128(10, 4)+3.0000 Decimal128(10, 4)# trunc with precision - decimalsquery RRRRR rowsort@@ -1372,21 +1372,21 @@ selecttrunc(arrow_cast(1.2837284, 'Decimal256(35,7)'), 2),trunc(arrow_cast(1.1, 'Decimal128(10,1)'), 0);-----4.267 1.12 -1.1231 1.28 1+4.267 1.120000 -1.1231 1.2800000 1.0# trunc with negative precision should truncate digits left of decimal - decimal typesquery RTselect trunc(arrow_cast(12345.678, 'Decimal128(10,3)'), -3),arrow_typeof(trunc(arrow_cast(12345.678, 'Decimal128(10,3)'), -3));-----12000 Decimal128(10, 3)+12000.000 Decimal128(10, 3)# trunc: coercion with a decimal argument and a non-int64 precision argumentquery RTselect trunc(arrow_cast(1.2345678, 'Decimal128(20,14)'), arrow_cast(2, 'Int32')),arrow_typeof(trunc(arrow_cast(1.2345678, 'Decimal128(20,14)'), arrow_cast(2, 'Int32')));-----1.23 Decimal128(20, 14)+1.23000000000000 Decimal128(20, 14)# trunc with columns and precision - decimal128query RRR rowsort@@ -1396,10 +1396,10 @@ selecttrunc(arrow_cast(c, 'Decimal128(10,4)'), 0) as c0from small_floats;------1 NULL NULL-0 0 -1-0 0 0-0 0 1+-1.0000 NULL NULL+0.0000 0.0000 -1.0000+0.0000 0.0000 0.0000+0.0000 0.0000 1.0000# trunc issue #22512query Rdiff --git a/datafusion/sqllogictest/test_files/spark/aggregate/try_sum.slt b/datafusion/sqllogictest/test_files/spark/aggregate/try_sum.sltindex 0f440a97dd..c9b5dabee6 100644--- a/datafusion/sqllogictest/test_files/spark/aggregate/try_sum.slt+++ b/datafusion/sqllogictest/test_files/spark/aggregate/try_sum.slt@@ -55,12 +55,12 @@ Infinityquery RSELECT try_sum(x) AS sum_x FROM VALUES (DECIMAL(10,2) '1.23'), (DECIMAL(10,2) '4.77') AS tab(x);-----6+6.00query RSELECT try_sum(x) AS sum_x FROM VALUES (DECIMAL(10,2) '1.00'), (NULL), (DECIMAL(10,2) '2.50') AS tab(x);-----3.5+3.50query RSELECT try_sum(x) AS sum_x FROM VALUES (DECIMAL(5,0) '90000'), (DECIMAL(5,0) '20000') AS tab(x);@@ -131,10 +131,10 @@ SELECT try_sum(col) AS sum_x FROM VALUES (CAST(-0.0 AS DOUBLE)), (CAST(0.0 AS DOquery RSELECT try_sum(col) AS sum_x FROM VALUES (CAST(-5.5 AS DECIMAL(10,2))), (CAST(5.5 AS DECIMAL(10,2))) AS tab(col);-----0+0.00# Compare double 0.0 vs decimal 0.00query RRSELECT 0.0 AS double_zero, CAST(0.0 AS DECIMAL(10,2)) AS decimal_zero;-----0 0+0 0.00diff --git a/datafusion/sqllogictest/test_files/spark/math/abs.slt b/datafusion/sqllogictest/test_files/spark/math/abs.sltindex 0a6953eefc..72d8fc9c9b 100644--- a/datafusion/sqllogictest/test_files/spark/math/abs.slt+++ b/datafusion/sqllogictest/test_files/spark/math/abs.slt@@ -73,23 +73,23 @@ SELECT abs(-1.0::DOUBLE), abs(0.::DOUBLE), abs(-0.::DOUBLE), abs(-0::DOUBLE), abquery RRRSELECT abs(('-99999999.99')::DECIMAL(10, 2)), abs(0::DECIMAL(10, 2)), abs(NULL::DECIMAL(10, 2));-----99999999.99 0 NULL+99999999.99 0.00 NULLquery RRRSELECT abs(('-9999999999999999999999999999.9999999999')::DECIMAL(38, 10)), abs(0::DECIMAL(38, 10)), abs(NULL::DECIMAL(38, 10));-----9999999999999999999999999999.9999999999 0 NULL+9999999999999999999999999999.9999999999 0.0000000000 NULL## Scalar input: decimal256query RRRSELECT abs(('-99999999999999999999999999999999999999.99')::DECIMAL(40, 2)), abs(0::DECIMAL(40, 2)), abs(NULL::DECIMAL(40, 2));-----99999999999999999999999999999999999999.99 0 NULL+99999999999999999999999999999999999999.99 0.00 NULLquery RRRSELECT abs(('-999999999999999999999999999999999999999999999999999999999999999999.9999999999')::DECIMAL(76, 10)), abs(0::DECIMAL(76, 10)), abs(NULL::DECIMAL(76, 10));-----999999999999999999999999999999999999999999999999999999999999999999.9999999999 0 NULL+999999999999999999999999999999999999999999999999999999999999999999.9999999999 0.0000000000 NULL# Array input@@ -181,14 +181,14 @@ query RSELECT abs(a) FROM (VALUES (('-99999999.99')::DECIMAL(10, 2)), (0::DECIMAL(10, 2)), (NULL::DECIMAL(10, 2))) AS t(a);----99999999.99-0+0.00NULLquery RSELECT abs(a) FROM (VALUES (('-9999999999999999999999999999.9999999999')::DECIMAL(38, 10)), (0::DECIMAL(38, 10)), (NULL::DECIMAL(38, 10))) AS t(a);----9999999999999999999999999999.9999999999-0+0.0000000000NULL## Array input: decimal256@@ -196,14 +196,14 @@ query RSELECT abs(a) FROM (VALUES (('-99999999999999999999999999999999999999.99')::DECIMAL(40, 2)), (0::DECIMAL(40, 2)), (NULL::DECIMAL(40, 2))) AS t(a);----99999999999999999999999999999999999999.99-0+0.00NULLquery RSELECT abs(a) FROM (VALUES (('-999999999999999999999999999999999999999999999999999999999999999999.9999999999')::DECIMAL(76, 10)), (0::DECIMAL(76, 10)), (NULL::DECIMAL(76, 10))) AS t(a);----999999999999999999999999999999999999999999999999999999999999999999.9999999999-0+0.0000000000NULL## Original Query: SELECT abs(INTERVAL -'1-1' YEAR TO MONTH);diff --git a/datafusion/sqllogictest/test_files/spark/math/mod.slt b/datafusion/sqllogictest/test_files/spark/math/mod.sltindex b9a8499939..7f8ac6bad8 100644--- a/datafusion/sqllogictest/test_files/spark/math/mod.slt+++ b/datafusion/sqllogictest/test_files/spark/math/mod.slt@@ -142,7 +142,7 @@ SELECT MOD(2.5::decimal(3,1), 1.2::decimal(2,1)) as mod_decimal_1;query RSELECT MOD(10.0::decimal(3,1), 3.0::decimal(2,1)) as mod_decimal_2;-----1+1.0# Division by zero returns NULL in legacy mode (ANSI off)query Idiff --git a/datafusion/sqllogictest/test_files/spark/math/pmod.slt b/datafusion/sqllogictest/test_files/spark/math/pmod.sltindex 1165fdfba3..672ac370d6 100644--- a/datafusion/sqllogictest/test_files/spark/math/pmod.slt+++ b/datafusion/sqllogictest/test_files/spark/math/pmod.slt@@ -246,7 +246,7 @@ SELECT CAST(pmod(15.8::float4, 4.2::float4) AS DECIMAL(3,1)) as pmod_float32_3;query RSELECT CAST(pmod(-15.8::float4, 4.2::float4) AS DECIMAL(3,1)) as pmod_float32_4;-----1+1.0# PMOD tests with special float valuesquery R@@ -298,12 +298,12 @@ SELECT pmod(-2.5::decimal(3,1), 1.2::decimal(2,1)) as pmod_decimal_2;query RSELECT pmod(10.0::decimal(3,1), 3.0::decimal(2,1)) as pmod_decimal_3;-----1+1.0query RSELECT pmod(-10.0::decimal(3,1), 3.0::decimal(2,1)) as pmod_decimal_4;-----2+2.0# PMOD tests with different integer typesquery Idiff --git a/datafusion/sqllogictest/test_files/spark/math/round.slt b/datafusion/sqllogictest/test_files/spark/math/round.sltindex 7fee15079d..309fbc1b52 100644--- a/datafusion/sqllogictest/test_files/spark/math/round.slt+++ b/datafusion/sqllogictest/test_files/spark/math/round.slt@@ -308,24 +308,24 @@ SELECT round(arrow_cast(42, 'UInt32'), 2::int);query RSELECT round(arrow_cast(2.5, 'Decimal32(9, 1)'), 0::int);-----3+3.0query RSELECT round(arrow_cast(-2.5, 'Decimal32(9, 1)'), 0::int);------3+-3.0# round(decimal32, 2)query RSELECT round(arrow_cast(2.345, 'Decimal32(9, 3)'), 2::int);-----2.35+2.350# round(decimal32) default scale = 0query RSELECT round(arrow_cast(3.5, 'Decimal32(9, 1)'));-----4+4.0# --- Decimal64 ---@@ -333,24 +333,24 @@ SELECT round(arrow_cast(3.5, 'Decimal32(9, 1)'));query RSELECT round(arrow_cast(2.5, 'Decimal64(18, 1)'), 0::int);-----3+3.0query RSELECT round(arrow_cast(-2.5, 'Decimal64(18, 1)'), 0::int);------3+-3.0# round(decimal64, 2)query RSELECT round(arrow_cast(2.345, 'Decimal64(18, 3)'), 2::int);-----2.35+2.350# round(decimal64) default scale = 0query RSELECT round(arrow_cast(3.5, 'Decimal64(18, 1)'));-----4+4.0# --- Decimal128 ---@@ -358,34 +358,34 @@ SELECT round(arrow_cast(3.5, 'Decimal64(18, 1)'));query RSELECT round(2.5::decimal(2,1), 0::int);-----3+3.0query RSELECT round(3.5::decimal(2,1), 0::int);-----4+4.0query RSELECT round(-2.5::decimal(2,1), 0::int);------3+-3.0# round(decimal) default scale = 0query RSELECT round(2.5::decimal(2,1));-----3+3.0# round(decimal, 2) — keep 2 decimal placesquery RSELECT round(2.345::decimal(10,3), 2::int);-----2.35+2.350query RSELECT round(2.355::decimal(10,3), 2::int);-----2.36+2.360# round(decimal, scale larger than input scale) — no changequery R@@ -397,19 +397,19 @@ SELECT round(2.5::decimal(2,1), 5::int);query RSELECT round(123.456::decimal(10,3), 1::int);-----123.5+123.500# round(decimal, negative scale) — round to tensquery RSELECT round(125.0::decimal(10,1), -1::int);-----130+130.0# round(decimal, extreme negative scale) — should return 0, not errorquery RSELECT round(2.5::decimal(10,1), -400::int);-----0+0.0# --- Decimal256 ---@@ -417,24 +417,24 @@ SELECT round(2.5::decimal(10,1), -400::int);query RSELECT round(arrow_cast(2.5, 'Decimal256(38, 1)'), 0::int);-----3+3.0query RSELECT round(arrow_cast(-2.5, 'Decimal256(38, 1)'), 0::int);------3+-3.0# round(decimal256, 2)query RSELECT round(arrow_cast(2.345, 'Decimal256(38, 3)'), 2::int);-----2.35+2.350# round(decimal256) default scale = 0query RSELECT round(arrow_cast(3.5, 'Decimal256(38, 1)'));-----4+4.0# -------------------------------------------------------------------# NULL handling@@ -481,10 +481,10 @@ CREATE TABLE test_round (id int, int_val int, float_val double, dec_val decimal(query IIRR rowsortSELECT id, round(int_val, -1::int), round(float_val), round(dec_val, 2::int) FROM test_round;-----1 30 3 2.35-2 40 4 3.56-3 -30 -3 -2.35-4 120 1 1.01+1 30 3 2.350+2 40 4 3.560+3 -30 -3 -2.350+4 120 1 1.0105 NULL NULL NULLstatement ok@@ -566,7 +566,7 @@ SELECT round(2.5::double);query RSELECT round(2.5::decimal(2,1), 0::int);-----3+3.0# ANSI mode: integer overflow should errorquery error DataFusion error: Execution error: Int64 overflow on rounddiff --git a/datafusion/sqllogictest/test_files/subquery.slt b/datafusion/sqllogictest/test_files/subquery.sltindex 2a022b947d..9040d55f25 100644--- a/datafusion/sqllogictest/test_files/subquery.slt+++ b/datafusion/sqllogictest/test_files/subquery.slt@@ -2624,8 +2624,8 @@ from (group by cntrycodeorder by cntrycode;-----18 1 30-29 1 40+18 1 30.00+29 1 40.00# `count(*)` over the same query must agree with the row count above.query Idiff --git a/datafusion/sqllogictest/test_files/tpch/answers/q1.slt.part b/datafusion/sqllogictest/test_files/tpch/answers/q1.slt.partindex bd8761bbb7..fa6f2680e2 100644--- a/datafusion/sqllogictest/test_files/tpch/answers/q1.slt.part+++ b/datafusion/sqllogictest/test_files/tpch/answers/q1.slt.part@@ -39,7 +39,7 @@ order byl_returnflag,l_linestatus;-----A F 3774200 5320753880.69 5054096266.6828 5256751331.449234 25.537587 36002.123829 0.050144 147790-N F 95257 133737795.84 127132372.6512 132286291.229445 25.300664 35521.326916 0.049394 3765-N O 7459297 10512270008.9 9986238338.3847 10385578376.585467 25.545537 36000.924688 0.050095 292000-R F 3785523 5337950526.47 5071818532.942 5274405503.049367 25.525943 35994.029214 0.049989 148301+A F 3774200.00 5320753880.69 5054096266.6828 5256751331.449234 25.537587 36002.123829 0.050144 147790+N F 95257.00 133737795.84 127132372.6512 132286291.229445 25.300664 35521.326916 0.049394 3765+N O 7459297.00 10512270008.90 9986238338.3847 10385578376.585467 25.545537 36000.924688 0.050095 292000+R F 3785523.00 5337950526.47 5071818532.9420 5274405503.049367 25.525943 35994.029214 0.049989 148301diff --git a/datafusion/sqllogictest/test_files/tpch/answers/q10.slt.part b/datafusion/sqllogictest/test_files/tpch/answers/q10.slt.partindex 8a8d1a00d9..384e28d804 100644--- a/datafusion/sqllogictest/test_files/tpch/answers/q10.slt.part+++ b/datafusion/sqllogictest/test_files/tpch/answers/q10.slt.part@@ -59,4 +59,4 @@ limit 10;13984 Customer#000013984 446316.5104 3482.28 IRAN qZXwuapCHvxbX 20-981-264-2952 y unusual courts could wake furiously1966 Customer#000001966 444059.0382 1937.72 ALGERIA jPv1 UHra5JLALR5Isci5u0636RoAu7t vH 10-973-269-8886 the blithely even accounts. final deposits cajole around the blithely final packages.11026 Customer#000011026 417913.4142 7738.76 ALGERIA XorIktoJOAEJkpNNMx 10-184-163-4632 ly even dolphins eat along the blithely even instructions. express attainments cajole slyly. busy dolphins in-8501 Customer#000008501 412797.51 6906.7 ARGENTINA 776af4rOa mZ66hczs 11-317-552-5840 y final deposits after the fluffily even accounts are slyly final, regular+8501 Customer#000008501 412797.5100 6906.70 ARGENTINA 776af4rOa mZ66hczs 11-317-552-5840 y final deposits after the fluffily even accounts are slyly final, regulardiff --git a/datafusion/sqllogictest/test_files/tpch/answers/q11.slt.part b/datafusion/sqllogictest/test_files/tpch/answers/q11.slt.partindex 53fb6bca29..a6ceb742be 100644--- a/datafusion/sqllogictest/test_files/tpch/answers/q11.slt.part+++ b/datafusion/sqllogictest/test_files/tpch/answers/q11.slt.part@@ -49,7 +49,7 @@ limit 10;12098 16227681.215134 15709338.5213334 15023662.41-17052 14351644.2+17052 14351644.203452 14070870.1412552 13332469.181084 13170428.29diff --git a/datafusion/sqllogictest/test_files/tpch/answers/q18.slt.part b/datafusion/sqllogictest/test_files/tpch/answers/q18.slt.partindex 93da210f51..5481f26f03 100644--- a/datafusion/sqllogictest/test_files/tpch/answers/q18.slt.part+++ b/datafusion/sqllogictest/test_files/tpch/answers/q18.slt.part@@ -50,8 +50,8 @@ order byo_totalprice desc,o_orderdate;-----Customer#000001639 1639 502886 1994-04-12 456423.88 312-Customer#000006655 6655 29158 1995-10-21 452805.02 305-Customer#000014110 14110 565574 1995-09-24 425099.85 301-Customer#000001775 1775 6882 1997-04-09 408368.1 303-Customer#000011459 11459 551136 1993-05-19 386812.74 308+Customer#000001639 1639 502886 1994-04-12 456423.88 312.00+Customer#000006655 6655 29158 1995-10-21 452805.02 305.00+Customer#000014110 14110 565574 1995-09-24 425099.85 301.00+Customer#000001775 1775 6882 1997-04-09 408368.10 303.00+Customer#000011459 11459 551136 1993-05-19 386812.74 308.00diff --git a/datafusion/sqllogictest/test_files/tpch/answers/q19.slt.part b/datafusion/sqllogictest/test_files/tpch/answers/q19.slt.partindex a8c6a5032d..bee10aadbf 100644--- a/datafusion/sqllogictest/test_files/tpch/answers/q19.slt.part+++ b/datafusion/sqllogictest/test_files/tpch/answers/q19.slt.part@@ -53,4 +53,4 @@ whereand l_shipinstruct = 'DELIVER IN PERSON');-----168597.286+168597.2860diff --git a/datafusion/sqllogictest/test_files/tpch/answers/q2.slt.part b/datafusion/sqllogictest/test_files/tpch/answers/q2.slt.partindex db4966c47b..56945d904d 100644--- a/datafusion/sqllogictest/test_files/tpch/answers/q2.slt.part+++ b/datafusion/sqllogictest/test_files/tpch/answers/q2.slt.part@@ -67,8 +67,8 @@ limit 10;9508.37 Supplier#000000070 FRANCE 17268 Manufacturer#4 INWNH2w,OOWgNDq0BRCcBwOMQc6PdFDc4 16-821-608-1166 ests sleep quickly express ideas. ironic ideas haggle about the final T9453.01 Supplier#000000802 ROMANIA 10021 Manufacturer#5 ,6HYXb4uaHITmtMBj4Ak57Pd 29-342-882-6463 gular frets. permanently special multipliers believe blithely alongs9453.01 Supplier#000000802 ROMANIA 13275 Manufacturer#4 ,6HYXb4uaHITmtMBj4Ak57Pd 29-342-882-6463 gular frets. permanently special multipliers believe blithely alongs-9192.1 Supplier#000000115 UNITED KINGDOM 13325 Manufacturer#1 nJ 2t0f7Ve,wL1,6WzGBJLNBUCKlsV 33-597-248-1220 es across the carefully express accounts boost caref+9192.10 Supplier#000000115 UNITED KINGDOM 13325 Manufacturer#1 nJ 2t0f7Ve,wL1,6WzGBJLNBUCKlsV 33-597-248-1220 es across the carefully express accounts boost caref9032.15 Supplier#000000959 GERMANY 4958 Manufacturer#4 8grA EHBnwOZhO 17-108-642-3106 nding dependencies nag furiou8702.02 Supplier#000000333 RUSSIA 11810 Manufacturer#3 MaVf XgwPdkiX4nfJGOis8Uu2zKiIZH 32-508-202-6136 oss the deposits cajole carefully even pinto beans. regular foxes detect alo-8615.5 Supplier#000000812 FRANCE 10551 Manufacturer#2 8qh4tezyScl5bidLAysvutB,,ZI2dn6xP 16-585-724-6633 y quickly regular deposits? quickly pending packages after the caref-8615.5 Supplier#000000812 FRANCE 13811 Manufacturer#4 8qh4tezyScl5bidLAysvutB,,ZI2dn6xP 16-585-724-6633 y quickly regular deposits? quickly pending packages after the caref+8615.50 Supplier#000000812 FRANCE 10551 Manufacturer#2 8qh4tezyScl5bidLAysvutB,,ZI2dn6xP 16-585-724-6633 y quickly regular deposits? quickly pending packages after the caref+8615.50 Supplier#000000812 FRANCE 13811 Manufacturer#4 8qh4tezyScl5bidLAysvutB,,ZI2dn6xP 16-585-724-6633 y quickly regular deposits? quickly pending packages after the carefdiff --git a/datafusion/sqllogictest/test_files/tpch/answers/q22.slt.part b/datafusion/sqllogictest/test_files/tpch/answers/q22.slt.partindex 2233826912..b32e0e9653 100644--- a/datafusion/sqllogictest/test_files/tpch/answers/q22.slt.part+++ b/datafusion/sqllogictest/test_files/tpch/answers/q22.slt.part@@ -61,4 +61,4 @@ order by23 93 708285.2529 85 632693.4630 87 646748.02-31 87 647372.5+31 87 647372.50diff --git a/datafusion/sqllogictest/test_files/tpch/answers/q3.slt.part b/datafusion/sqllogictest/test_files/tpch/answers/q3.slt.partindex 1e7fc0a961..dbfdd12524 100644--- a/datafusion/sqllogictest/test_files/tpch/answers/q3.slt.part+++ b/datafusion/sqllogictest/test_files/tpch/answers/q3.slt.part@@ -44,10 +44,10 @@ order by223140 355369.0698 1995-03-14 0584291 354494.7318 1995-02-21 0405063 353125.4577 1995-03-03 0-573861 351238.277 1995-03-09 0+573861 351238.2770 1995-03-09 0554757 349181.7426 1995-03-14 0-506021 321075.581 1995-03-10 0+506021 321075.5810 1995-03-10 0121604 318576.4154 1995-03-07 0108514 314967.0754 1995-02-20 0-462502 312604.542 1995-03-08 0+462502 312604.5420 1995-03-08 0178727 309728.9306 1995-02-25 0diff --git a/datafusion/sqllogictest/test_files/tpch/answers/q5.slt.part b/datafusion/sqllogictest/test_files/tpch/answers/q5.slt.partindex 75e2fa316f..5123df1254 100644--- a/datafusion/sqllogictest/test_files/tpch/answers/q5.slt.part+++ b/datafusion/sqllogictest/test_files/tpch/answers/q5.slt.part@@ -42,7 +42,7 @@ group byorder byrevenue desc;-----CHINA 7822103+CHINA 7822103.0000INDIA 6376121.5085JAPAN 6000077.2184INDONESIA 5580475.4027diff --git a/datafusion/sqllogictest/test_files/window.slt b/datafusion/sqllogictest/test_files/window.sltindex 230fb02055..bd3eb6ba39 100644--- a/datafusion/sqllogictest/test_files/window.slt+++ b/datafusion/sqllogictest/test_files/window.slt@@ -6600,9 +6600,9 @@ FROM ()ORDER BY a;-----1.5 1.5 2.5-2.5 1.5 3.5-3.5 2.5 3.5+1.50 1.50 2.50+2.50 1.50 3.50+3.50 2.50 3.50############################################################################# ROWS frame regression guard: huge offsets already saturate via@@ -6825,8 +6825,8 @@ FROM (VALUES(1,CAST(1.5 AS DECIMAL(10,2))),(4,CAST(NULL AS DECIMAL(10,2)))) t(i,v)ORDER BY i;-----1 2-2 2.5+1 2.000000+2 2.5000003 NULL4 NULL@@ -7062,8 +7062,8 @@ FROM (VALUES (arrow_cast(1.5, 'Decimal128(10, 2)')),(arrow_cast(2.0, 'Decimal128(10, 2)'))) t(x)ORDER BY x-----1.5 1-2 2+1.50 1+2.00 2# Free range frames over those same types keep working, so the rejection above is# narrowed to the offset form rather than to the order key type as a whole.