You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2021/12/07 11:35:20 UTC
[arrow-datafusion] branch master updated: Be consistent with pg on real datatype (#1390)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/master by this push:
new b9866e6 Be consistent with pg on real datatype (#1390)
b9866e6 is described below
commit b9866e62800700dd322e755cfbbbff6b0df48fa2
Author: Stephen Carman <hn...@users.noreply.github.com>
AuthorDate: Tue Dec 7 06:35:12 2021 -0500
Be consistent with pg on real datatype (#1390)
* Be consistent with pg on real datatype
* Quick test to check casting to real creates correct datatype
Co-authored-by: Stephen Carman <sc...@lendingclub.com>
---
datafusion/src/sql/planner.rs | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/datafusion/src/sql/planner.rs b/datafusion/src/sql/planner.rs
index ac3d3b1..0f9a8c0 100644
--- a/datafusion/src/sql/planner.rs
+++ b/datafusion/src/sql/planner.rs
@@ -374,7 +374,8 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
}
SQLDataType::Decimal(_, _) => Ok(DataType::Float64),
SQLDataType::Float(_) => Ok(DataType::Float32),
- SQLDataType::Real | SQLDataType::Double => Ok(DataType::Float64),
+ SQLDataType::Real => Ok(DataType::Float32),
+ SQLDataType::Double => Ok(DataType::Float64),
SQLDataType::Boolean => Ok(DataType::Boolean),
SQLDataType::Date => Ok(DataType::Date32),
SQLDataType::Time => Ok(DataType::Time64(TimeUnit::Millisecond)),
@@ -1991,7 +1992,8 @@ pub fn convert_data_type(sql: &SQLDataType) -> Result<DataType> {
SQLDataType::SmallInt(_display) => Ok(DataType::Int16),
SQLDataType::Int(_display) => Ok(DataType::Int32),
SQLDataType::BigInt(_display) => Ok(DataType::Int64),
- SQLDataType::Float(_) | SQLDataType::Real => Ok(DataType::Float64),
+ SQLDataType::Float(_) => Ok(DataType::Float64),
+ SQLDataType::Real => Ok(DataType::Float32),
SQLDataType::Double => Ok(DataType::Float64),
SQLDataType::Char(_) | SQLDataType::Varchar(_) => Ok(DataType::Utf8),
SQLDataType::Timestamp => Ok(DataType::Timestamp(TimeUnit::Nanosecond, None)),
@@ -2021,6 +2023,15 @@ mod tests {
}
#[test]
+ fn test_real_f32() {
+ quick_test(
+ "SELECT CAST(1.1 AS REAL)",
+ "Projection: CAST(Float64(1.1) AS Float32)\
+ \n EmptyRelation",
+ );
+ }
+
+ #[test]
fn select_column_does_not_exist() {
let sql = "SELECT doesnotexist FROM person";
let err = logical_plan(sql).expect_err("query should have failed");