Apache DataFusion SQL Query Engine
remove old unimplemented() for scientific notaion (#6142)
Yongting Youa31786e20a5b
diff --git a/datafusion/core/tests/sqllogictests/test_files/scalar.slt b/datafusion/core/tests/sqllogictests/test_files/scalar.sltindex 7583600802..12248f894f 100644--- a/datafusion/core/tests/sqllogictests/test_files/scalar.slt+++ b/datafusion/core/tests/sqllogictests/test_files/scalar.slt@@ -820,3 +820,40 @@ drop table test_booleanstatement okdrop table test_int32++# scientific notation (0s)+query RRRR+SELECT 0e0 AS c1, 0.e-0 AS c2, -.0e+0 AS c3, 00.00e-00 AS c4+----+0 0 0 0++# scientific notation (integer)+query RRRR+SELECT -1e-1, 0e100, 10E-2, 1E+0;+----+-0.1 0 0.1 1++# scientific notation (decimal)+query RRRR+SELECT -1.5e-1, 00.0e1, 150.0E-3, 0.015E+2;+----+-0.15 0 0.15 1.5++# scientific notation (integer or decimal part only)+query RRRR+SELECT -2.e-1, 0.e0, .0002E+3, .02E+2;+----+-0.2 0 0.2 2++# scientific notation (overflows)+# FLOAT64 range: -1.79E+308 to -2.22E-308, or from 2.22E-308 to 1.79E+308+query RRRR+SELECT -1.79e309, -2.22e-309, 2.22E-309, 1.79E+309;+----+-Infinity 0 0 Infinity++# scientific notation (other edgecases)+query IRRR+SELECT 1ea, 1e-2a, 1E-2-2, 1E-1e2;+----+1 0.01 -1.99 0.1diff --git a/datafusion/sql/src/expr/value.rs b/datafusion/sql/src/expr/value.rsindex c936313e20..df9e44be3f 100644--- a/datafusion/sql/src/expr/value.rs+++ b/datafusion/sql/src/expr/value.rs@@ -47,14 +47,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {/// Parse number in sql string, convert to Expr::Literalfn parse_sql_number(&self, n: &str) -> Result<Expr> {- if n.find('E').is_some() {- // not implemented yet- // https://github.com/apache/arrow-datafusion/issues/3448- Err(DataFusionError::NotImplemented(- "sql numeric literals in scientific notation are not supported"- .to_string(),- ))- } else if let Ok(n) = n.parse::<i64>() {+ if let Ok(n) = n.parse::<i64>() {Ok(lit(n))} else if self.options.parse_float_as_decimal {// remove leading zeroes