From b325670ed47b97b0942c3655a916e71394400d28 Mon Sep 17 00:00:00 2001 From: Weijun Huang Date: Mon, 11 Dec 2023 16:01:00 +0100 Subject: [PATCH 1/7] support scientific notation --- datafusion/sql/src/expr/value.rs | 37 ++++++++++++++++--- .../sqllogictest/test_files/options.slt | 12 ++++++ 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/datafusion/sql/src/expr/value.rs b/datafusion/sql/src/expr/value.rs index 708f7c60011a..58fb6db8b067 100644 --- a/datafusion/sql/src/expr/value.rs +++ b/datafusion/sql/src/expr/value.rs @@ -18,7 +18,7 @@ use crate::planner::{ContextProvider, PlannerContext, SqlToRel}; use arrow::compute::kernels::cast_utils::parse_interval_month_day_nano; use arrow::datatypes::DECIMAL128_MAX_PRECISION; -use arrow_schema::DataType; +use arrow_schema::{DataType, DECIMAL128_MAX_SCALE}; use datafusion_common::{ not_impl_err, plan_err, DFSchema, DataFusionError, Result, ScalarValue, }; @@ -405,11 +405,29 @@ const fn try_decode_hex_char(c: u8) -> Option { } /// Parse Decimal128 from a string -/// -/// TODO: support parsing from scientific notation fn parse_decimal_128(unsigned_number: &str, negative: bool) -> Result { // remove leading zeroes let trimmed = unsigned_number.trim_start_matches('0'); + + // check if the number is scientific notation + let parts = trimmed.split(|c| c == 'e' || c == 'E').collect::>(); + + let (trimmed, e_scale) = if parts.len() == 1 { + (trimmed, 0) + } else if parts.len() == 2 { + let e_scale = parts[1].parse::().map_err(|e| { + DataFusionError::from(ParserError(format!( + "Cannot parse {} as i32 when building decimal: {e}", + parts[1] + ))) + })?; + (parts[0], e_scale) + } else { + return Err(DataFusionError::from(ParserError(format!( + "Cannot parse {unsigned_number} as i128 when building decimal: invalid format" + )))); + }; + // parse precision and scale, remove decimal point if exists let (precision, scale, replaced_str) = if trimmed == "." { // special cases for numbers such as “0.”, “000.”, and so on. @@ -425,6 +443,12 @@ fn parse_decimal_128(unsigned_number: &str, negative: bool) -> Result { (trimmed.len(), 0, Cow::Borrowed(trimmed)) }; + let (precision, scale) = if e_scale > 0 { + (precision as i32 + e_scale, scale as i32 - e_scale) + } else { + (precision as i32 - e_scale, scale as i32 - e_scale) + }; + let number = replaced_str.parse::().map_err(|e| { DataFusionError::from(ParserError(format!( "Cannot parse {replaced_str} as i128 when building decimal: {e}" @@ -432,10 +456,11 @@ fn parse_decimal_128(unsigned_number: &str, negative: bool) -> Result { })?; // check precision overflow - if precision as u8 > DECIMAL128_MAX_PRECISION { + if precision > DECIMAL128_MAX_PRECISION as i32 || scale > DECIMAL128_MAX_SCALE as i32 + { return Err(DataFusionError::from(ParserError(format!( - "Cannot parse {replaced_str} as i128 when building decimal: precision overflow" - )))); + "Cannot parse {replaced_str} as i128 when building decimal: precision overflow" + )))); } Ok(Expr::Literal(ScalarValue::Decimal128( diff --git a/datafusion/sqllogictest/test_files/options.slt b/datafusion/sqllogictest/test_files/options.slt index 9366a9b3b3c8..d26c7f705eb5 100644 --- a/datafusion/sqllogictest/test_files/options.slt +++ b/datafusion/sqllogictest/test_files/options.slt @@ -206,6 +206,18 @@ select 123456789.0123456789012345678901234567890 statement error SQL error: ParserError\("Cannot parse 1234567890123456789012345678901234567890 as i128 when building decimal: number too large to fit in target type"\) select -123456789.0123456789012345678901234567890 +# scientific notation +query RRRR +select 1.234e2, 1.234e-2, -1.234e2, -1.234e-2 +---- +123.4 0.01234 -123.4 -0.01234 + +statement error DataFusion error: SQL error: ParserError\("Cannot parse 1234 as i128 when building decimal: precision overflow"\) +select 1.234e-38 + +statement error DataFusion error: SQL error: ParserError\("Cannot parse 1234 as i128 when building decimal: precision overflow"\) +select 1.234e+38 + # Restore option to default value statement ok set datafusion.sql_parser.parse_float_as_decimal = false; From b64e41bf4e733bf9fca4f7acb1b6af37b99e5d62 Mon Sep 17 00:00:00 2001 From: Weijun Huang Date: Mon, 11 Dec 2023 16:20:44 +0100 Subject: [PATCH 2/7] parse number to i16 --- datafusion/sql/src/expr/value.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/datafusion/sql/src/expr/value.rs b/datafusion/sql/src/expr/value.rs index 58fb6db8b067..42f1d1b27b00 100644 --- a/datafusion/sql/src/expr/value.rs +++ b/datafusion/sql/src/expr/value.rs @@ -415,7 +415,7 @@ fn parse_decimal_128(unsigned_number: &str, negative: bool) -> Result { let (trimmed, e_scale) = if parts.len() == 1 { (trimmed, 0) } else if parts.len() == 2 { - let e_scale = parts[1].parse::().map_err(|e| { + let e_scale = parts[1].parse::().map_err(|e| { DataFusionError::from(ParserError(format!( "Cannot parse {} as i32 when building decimal: {e}", parts[1] @@ -444,9 +444,9 @@ fn parse_decimal_128(unsigned_number: &str, negative: bool) -> Result { }; let (precision, scale) = if e_scale > 0 { - (precision as i32 + e_scale, scale as i32 - e_scale) + (precision as i16 + e_scale, scale as i16 - e_scale) } else { - (precision as i32 - e_scale, scale as i32 - e_scale) + (precision as i16 - e_scale, scale as i16 - e_scale) }; let number = replaced_str.parse::().map_err(|e| { @@ -456,7 +456,7 @@ fn parse_decimal_128(unsigned_number: &str, negative: bool) -> Result { })?; // check precision overflow - if precision > DECIMAL128_MAX_PRECISION as i32 || scale > DECIMAL128_MAX_SCALE as i32 + if precision > DECIMAL128_MAX_PRECISION as i16 || scale > DECIMAL128_MAX_SCALE as i16 { return Err(DataFusionError::from(ParserError(format!( "Cannot parse {replaced_str} as i128 when building decimal: precision overflow" @@ -493,4 +493,10 @@ mod tests { assert_eq!(output, expect); } } + + #[test] + fn test_parse_128_decimal_number() { + let number = "1.23456e10"; + parse_decimal_128(number, false).unwrap(); + } } From 48fd8659914a957dd66f4c9c38b63959878515c9 Mon Sep 17 00:00:00 2001 From: Weijun Huang Date: Fri, 15 Dec 2023 10:00:54 +0100 Subject: [PATCH 3/7] use BigDecimal --- datafusion-cli/Cargo.lock | 14 +++ datafusion/sql/Cargo.toml | 1 + datafusion/sql/src/expr/value.rs | 85 +++++++++---------- .../sqllogictest/test_files/options.slt | 18 ++-- 4 files changed, 64 insertions(+), 54 deletions(-) diff --git a/datafusion-cli/Cargo.lock b/datafusion-cli/Cargo.lock index 76be04d5ef67..1b9564aec1f4 100644 --- a/datafusion-cli/Cargo.lock +++ b/datafusion-cli/Cargo.lock @@ -725,6 +725,19 @@ dependencies = [ "vsimd", ] +[[package]] +name = "bigdecimal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06619be423ea5bb86c95f087d5707942791a08a85530df0db2209a3ecfb8bc9" +dependencies = [ + "autocfg", + "libm", + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -1305,6 +1318,7 @@ version = "33.0.0" dependencies = [ "arrow", "arrow-schema", + "bigdecimal", "datafusion-common", "datafusion-expr", "log", diff --git a/datafusion/sql/Cargo.toml b/datafusion/sql/Cargo.toml index b91a2ac1fbd7..c817d0451c1c 100644 --- a/datafusion/sql/Cargo.toml +++ b/datafusion/sql/Cargo.toml @@ -39,6 +39,7 @@ unicode_expressions = [] [dependencies] arrow = { workspace = true } arrow-schema = { workspace = true } +bigdecimal = { workspace = true } datafusion-common = { workspace = true } datafusion-expr = { workspace = true } log = { workspace = true } diff --git a/datafusion/sql/src/expr/value.rs b/datafusion/sql/src/expr/value.rs index 42f1d1b27b00..43695537140f 100644 --- a/datafusion/sql/src/expr/value.rs +++ b/datafusion/sql/src/expr/value.rs @@ -17,8 +17,9 @@ use crate::planner::{ContextProvider, PlannerContext, SqlToRel}; use arrow::compute::kernels::cast_utils::parse_interval_month_day_nano; -use arrow::datatypes::DECIMAL128_MAX_PRECISION; +use arrow::datatypes::{ArrowNativeTypeOp, DECIMAL128_MAX_PRECISION}; use arrow_schema::{DataType, DECIMAL128_MAX_SCALE}; +use bigdecimal::BigDecimal; use datafusion_common::{ not_impl_err, plan_err, DFSchema, DataFusionError, Result, ScalarValue, }; @@ -30,6 +31,7 @@ use log::debug; use sqlparser::ast::{BinaryOperator, Expr as SQLExpr, Interval, Value}; use sqlparser::parser::ParserError::ParserError; use std::borrow::Cow; +use std::str::FromStr; impl<'a, S: ContextProvider> SqlToRel<'a, S> { pub(crate) fn parse_value( @@ -406,48 +408,40 @@ const fn try_decode_hex_char(c: u8) -> Option { /// Parse Decimal128 from a string fn parse_decimal_128(unsigned_number: &str, negative: bool) -> Result { - // remove leading zeroes - let trimmed = unsigned_number.trim_start_matches('0'); - - // check if the number is scientific notation - let parts = trimmed.split(|c| c == 'e' || c == 'E').collect::>(); - - let (trimmed, e_scale) = if parts.len() == 1 { - (trimmed, 0) - } else if parts.len() == 2 { - let e_scale = parts[1].parse::().map_err(|e| { - DataFusionError::from(ParserError(format!( - "Cannot parse {} as i32 when building decimal: {e}", - parts[1] - ))) - })?; - (parts[0], e_scale) - } else { - return Err(DataFusionError::from(ParserError(format!( - "Cannot parse {unsigned_number} as i128 when building decimal: invalid format" - )))); - }; + let big_decimal = BigDecimal::from_str(unsigned_number).map_err(|e| { + DataFusionError::from(ParserError(format!( + "Cannot parse {unsigned_number} into BigDecimal when building decimal: {e}" + ))) + })?; - // parse precision and scale, remove decimal point if exists - let (precision, scale, replaced_str) = if trimmed == "." { - // special cases for numbers such as “0.”, “000.”, and so on. - (1, 0, Cow::Borrowed("0")) - } else if let Some(i) = trimmed.find('.') { + let replaced_str = big_decimal.to_string().replace(".", ""); + + let (precision, scale) = if big_decimal.fractional_digit_count() < 0 { ( - trimmed.len() - 1, - trimmed.len() - i - 1, - Cow::Owned(trimmed.replace('.', "")), + (replaced_str.len() as i64) + .add_checked(big_decimal.fractional_digit_count())? as u64, + big_decimal.fractional_digit_count(), ) } else { - // no decimal point, keep as is - (trimmed.len(), 0, Cow::Borrowed(trimmed)) + ( + replaced_str.len() as u64, + big_decimal.fractional_digit_count(), + ) }; - let (precision, scale) = if e_scale > 0 { - (precision as i16 + e_scale, scale as i16 - e_scale) - } else { - (precision as i16 - e_scale, scale as i16 - e_scale) - }; + // check precision overflow + if precision > DECIMAL128_MAX_PRECISION as u64 { + return Err(DataFusionError::from(ParserError(format!( + "Cannot parse {unsigned_number} as i128 when building decimal: precision overflow" + )))); + } + + // check scale overflow + if scale < -DECIMAL128_MAX_SCALE as i64 || scale > DECIMAL128_MAX_SCALE as i64 { + return Err(DataFusionError::from(ParserError(format!( + "Cannot parse {unsigned_number} as i128 when building decimal: scale overflow" + )))); + } let number = replaced_str.parse::().map_err(|e| { DataFusionError::from(ParserError(format!( @@ -455,14 +449,6 @@ fn parse_decimal_128(unsigned_number: &str, negative: bool) -> Result { ))) })?; - // check precision overflow - if precision > DECIMAL128_MAX_PRECISION as i16 || scale > DECIMAL128_MAX_SCALE as i16 - { - return Err(DataFusionError::from(ParserError(format!( - "Cannot parse {replaced_str} as i128 when building decimal: precision overflow" - )))); - } - Ok(Expr::Literal(ScalarValue::Decimal128( Some(if negative { -number } else { number }), precision as u8, @@ -499,4 +485,13 @@ mod tests { let number = "1.23456e10"; parse_decimal_128(number, false).unwrap(); } + + #[test] + fn demo() { + let b = BigDecimal::from_str("00000.00").unwrap(); // Fractional part + println!("b: {:?}", b.to_string()); + println!("digits: {:?}", b.digits()); + println!("fractional_digit_count: {:?}", b.fractional_digit_count()); + let string = "0.0".parse::().unwrap(); + } } diff --git a/datafusion/sqllogictest/test_files/options.slt b/datafusion/sqllogictest/test_files/options.slt index d26c7f705eb5..d47ce039aee8 100644 --- a/datafusion/sqllogictest/test_files/options.slt +++ b/datafusion/sqllogictest/test_files/options.slt @@ -147,7 +147,7 @@ select .0 as c1, 0. as c2, 0000. as c3, 00000.00 as c4 query TTTT select arrow_typeof(.0) as c1, arrow_typeof(0.) as c2, arrow_typeof(0000.) as c3, arrow_typeof(00000.00) as c4 ---- -Decimal128(1, 1) Decimal128(1, 0) Decimal128(1, 0) Decimal128(2, 2) +Decimal128(2, 1) Decimal128(1, 0) Decimal128(1, 0) Decimal128(3, 2) query RR select 999999999999999999999999999999999999, -999999999999999999999999999999999999 @@ -193,17 +193,17 @@ select arrow_typeof(00009999999999999999999999999999999999.9999), Decimal128(38, 4) Decimal128(38, 4) Decimal128(20, 0) # precision overflow -statement error DataFusion error: SQL error: ParserError\("Cannot parse 123456789012345678901234567890123456789 as i128 when building decimal: precision overflow"\) +statement error DataFusion error: SQL error: ParserError\("Cannot parse 123456789.012345678901234567890123456789 as i128 when building decimal: precision overflow"\) select 123456789.012345678901234567890123456789 -statement error SQL error: ParserError\("Cannot parse 123456789012345678901234567890123456789 as i128 when building decimal: precision overflow"\) +statement error SQL error: ParserError\("Cannot parse 123456789.012345678901234567890123456789 as i128 when building decimal: precision overflow"\) select -123456789.012345678901234567890123456789 # can not fit in i128 -statement error SQL error: ParserError\("Cannot parse 1234567890123456789012345678901234567890 as i128 when building decimal: number too large to fit in target type"\) +statement error SQL error: ParserError\("Cannot parse 123456789.0123456789012345678901234567890 as i128 when building decimal: precision overflow"\) select 123456789.0123456789012345678901234567890 -statement error SQL error: ParserError\("Cannot parse 1234567890123456789012345678901234567890 as i128 when building decimal: number too large to fit in target type"\) +statement error SQL error: ParserError\("Cannot parse 123456789.0123456789012345678901234567890 as i128 when building decimal: precision overflow"\) select -123456789.0123456789012345678901234567890 # scientific notation @@ -212,11 +212,11 @@ select 1.234e2, 1.234e-2, -1.234e2, -1.234e-2 ---- 123.4 0.01234 -123.4 -0.01234 -statement error DataFusion error: SQL error: ParserError\("Cannot parse 1234 as i128 when building decimal: precision overflow"\) -select 1.234e-38 +statement error DataFusion error: SQL error: ParserError\("Cannot parse 1.234e-40 as i128 when building decimal: precision overflow"\) +select 1.234e-40 -statement error DataFusion error: SQL error: ParserError\("Cannot parse 1234 as i128 when building decimal: precision overflow"\) -select 1.234e+38 +statement error DataFusion error: SQL error: ParserError\("Cannot parse 12340000000000000000000000000000000000000 as i128 when building decimal: number too large to fit in target type"\) +select 1.234e+40 # Restore option to default value statement ok From c6d6e28effc7baeb970426043584d7b3871dc330 Mon Sep 17 00:00:00 2001 From: Weijun Huang Date: Fri, 15 Dec 2023 10:50:56 +0100 Subject: [PATCH 4/7] fix ci --- datafusion/sql/src/expr/value.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/datafusion/sql/src/expr/value.rs b/datafusion/sql/src/expr/value.rs index 43695537140f..1a99adef4c58 100644 --- a/datafusion/sql/src/expr/value.rs +++ b/datafusion/sql/src/expr/value.rs @@ -414,7 +414,7 @@ fn parse_decimal_128(unsigned_number: &str, negative: bool) -> Result { ))) })?; - let replaced_str = big_decimal.to_string().replace(".", ""); + let replaced_str = big_decimal.to_string().replace('.', ""); let (precision, scale) = if big_decimal.fractional_digit_count() < 0 { ( @@ -485,13 +485,4 @@ mod tests { let number = "1.23456e10"; parse_decimal_128(number, false).unwrap(); } - - #[test] - fn demo() { - let b = BigDecimal::from_str("00000.00").unwrap(); // Fractional part - println!("b: {:?}", b.to_string()); - println!("digits: {:?}", b.digits()); - println!("fractional_digit_count: {:?}", b.fractional_digit_count()); - let string = "0.0".parse::().unwrap(); - } } From 5098b17355cc14f3defdec9d5a7becc6df2b96c7 Mon Sep 17 00:00:00 2001 From: Weijun Huang Date: Fri, 15 Dec 2023 11:24:53 +0100 Subject: [PATCH 5/7] fix ci --- datafusion/sql/tests/sql_integration.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datafusion/sql/tests/sql_integration.rs b/datafusion/sql/tests/sql_integration.rs index 48ba50145308..41083b23a39f 100644 --- a/datafusion/sql/tests/sql_integration.rs +++ b/datafusion/sql/tests/sql_integration.rs @@ -43,8 +43,8 @@ fn parse_decimals() { let test_data = [ ("1", "Int64(1)"), ("001", "Int64(1)"), - ("0.1", "Decimal128(Some(1),1,1)"), - ("0.01", "Decimal128(Some(1),2,2)"), + ("0.1", "Decimal128(Some(1),2,1)"), + ("0.01", "Decimal128(Some(1),3,2)"), ("1.0", "Decimal128(Some(10),2,1)"), ("10.01", "Decimal128(Some(1001),4,2)"), ( From b04084a64fd2825394474d9a472e392251fa7625 Mon Sep 17 00:00:00 2001 From: Weijun Huang Date: Fri, 15 Dec 2023 13:19:41 +0100 Subject: [PATCH 6/7] fix ci --- datafusion/sql/src/expr/value.rs | 33 ++++++------------- datafusion/sql/tests/sql_integration.rs | 4 +-- .../sqllogictest/test_files/options.slt | 2 +- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/datafusion/sql/src/expr/value.rs b/datafusion/sql/src/expr/value.rs index 1a99adef4c58..041e185c7e5e 100644 --- a/datafusion/sql/src/expr/value.rs +++ b/datafusion/sql/src/expr/value.rs @@ -19,7 +19,7 @@ use crate::planner::{ContextProvider, PlannerContext, SqlToRel}; use arrow::compute::kernels::cast_utils::parse_interval_month_day_nano; use arrow::datatypes::{ArrowNativeTypeOp, DECIMAL128_MAX_PRECISION}; use arrow_schema::{DataType, DECIMAL128_MAX_SCALE}; -use bigdecimal::BigDecimal; +use bigdecimal::{BigDecimal, ToPrimitive}; use datafusion_common::{ not_impl_err, plan_err, DFSchema, DataFusionError, Result, ScalarValue, }; @@ -414,19 +414,12 @@ fn parse_decimal_128(unsigned_number: &str, negative: bool) -> Result { ))) })?; - let replaced_str = big_decimal.to_string().replace('.', ""); - - let (precision, scale) = if big_decimal.fractional_digit_count() < 0 { - ( - (replaced_str.len() as i64) - .add_checked(big_decimal.fractional_digit_count())? as u64, - big_decimal.fractional_digit_count(), - ) + let (big_int, scale) = big_decimal.clone().into_bigint_and_exponent(); + let precision = if scale <= 0 { + big_int.to_string().len() as u64 } else { - ( - replaced_str.len() as u64, - big_decimal.fractional_digit_count(), - ) + let precision = big_int.to_string().len() as u64; + precision.max(scale as u64) }; // check precision overflow @@ -436,16 +429,16 @@ fn parse_decimal_128(unsigned_number: &str, negative: bool) -> Result { )))); } - // check scale overflow - if scale < -DECIMAL128_MAX_SCALE as i64 || scale > DECIMAL128_MAX_SCALE as i64 { + // // check scale overflow + if scale > DECIMAL128_MAX_SCALE as i64 { return Err(DataFusionError::from(ParserError(format!( "Cannot parse {unsigned_number} as i128 when building decimal: scale overflow" )))); } - let number = replaced_str.parse::().map_err(|e| { + let number = big_int.to_i128().ok_or_else(|| { DataFusionError::from(ParserError(format!( - "Cannot parse {replaced_str} as i128 when building decimal: {e}" + "Cannot parse {unsigned_number} as i128 when building decimal" ))) })?; @@ -479,10 +472,4 @@ mod tests { assert_eq!(output, expect); } } - - #[test] - fn test_parse_128_decimal_number() { - let number = "1.23456e10"; - parse_decimal_128(number, false).unwrap(); - } } diff --git a/datafusion/sql/tests/sql_integration.rs b/datafusion/sql/tests/sql_integration.rs index 41083b23a39f..48ba50145308 100644 --- a/datafusion/sql/tests/sql_integration.rs +++ b/datafusion/sql/tests/sql_integration.rs @@ -43,8 +43,8 @@ fn parse_decimals() { let test_data = [ ("1", "Int64(1)"), ("001", "Int64(1)"), - ("0.1", "Decimal128(Some(1),2,1)"), - ("0.01", "Decimal128(Some(1),3,2)"), + ("0.1", "Decimal128(Some(1),1,1)"), + ("0.01", "Decimal128(Some(1),2,2)"), ("1.0", "Decimal128(Some(10),2,1)"), ("10.01", "Decimal128(Some(1001),4,2)"), ( diff --git a/datafusion/sqllogictest/test_files/options.slt b/datafusion/sqllogictest/test_files/options.slt index d47ce039aee8..665d07209ef2 100644 --- a/datafusion/sqllogictest/test_files/options.slt +++ b/datafusion/sqllogictest/test_files/options.slt @@ -147,7 +147,7 @@ select .0 as c1, 0. as c2, 0000. as c3, 00000.00 as c4 query TTTT select arrow_typeof(.0) as c1, arrow_typeof(0.) as c2, arrow_typeof(0000.) as c3, arrow_typeof(00000.00) as c4 ---- -Decimal128(2, 1) Decimal128(1, 0) Decimal128(1, 0) Decimal128(3, 2) +Decimal128(1, 1) Decimal128(1, 0) Decimal128(1, 0) Decimal128(2, 2) query RR select 999999999999999999999999999999999999, -999999999999999999999999999999999999 From b50d5c1759fa9732c69d10f91a9b5768a7ee4cf8 Mon Sep 17 00:00:00 2001 From: Weijun Huang Date: Fri, 15 Dec 2023 13:21:03 +0100 Subject: [PATCH 7/7] fix ci --- datafusion/sql/src/expr/value.rs | 2 +- datafusion/sqllogictest/test_files/options.slt | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/datafusion/sql/src/expr/value.rs b/datafusion/sql/src/expr/value.rs index 041e185c7e5e..2a59d75c549e 100644 --- a/datafusion/sql/src/expr/value.rs +++ b/datafusion/sql/src/expr/value.rs @@ -17,7 +17,7 @@ use crate::planner::{ContextProvider, PlannerContext, SqlToRel}; use arrow::compute::kernels::cast_utils::parse_interval_month_day_nano; -use arrow::datatypes::{ArrowNativeTypeOp, DECIMAL128_MAX_PRECISION}; +use arrow::datatypes::DECIMAL128_MAX_PRECISION; use arrow_schema::{DataType, DECIMAL128_MAX_SCALE}; use bigdecimal::{BigDecimal, ToPrimitive}; use datafusion_common::{ diff --git a/datafusion/sqllogictest/test_files/options.slt b/datafusion/sqllogictest/test_files/options.slt index 665d07209ef2..5907da89ca72 100644 --- a/datafusion/sqllogictest/test_files/options.slt +++ b/datafusion/sqllogictest/test_files/options.slt @@ -215,9 +215,6 @@ select 1.234e2, 1.234e-2, -1.234e2, -1.234e-2 statement error DataFusion error: SQL error: ParserError\("Cannot parse 1.234e-40 as i128 when building decimal: precision overflow"\) select 1.234e-40 -statement error DataFusion error: SQL error: ParserError\("Cannot parse 12340000000000000000000000000000000000000 as i128 when building decimal: number too large to fit in target type"\) -select 1.234e+40 - # Restore option to default value statement ok set datafusion.sql_parser.parse_float_as_decimal = false;