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/09 14:39:58 UTC
[arrow-datafusion] branch master updated: Make `FLOAT` SQL type map to `Float32` rather than `Float64` (#1423)
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 8295412 Make `FLOAT` SQL type map to `Float32` rather than `Float64` (#1423)
8295412 is described below
commit 8295412848bc7b5f2ce76377e8e70bbadecb551a
Author: Kun Liu <li...@apache.org>
AuthorDate: Thu Dec 9 22:39:52 2021 +0800
Make `FLOAT` SQL type map to `Float32` rather than `Float64` (#1423)
* minor fix and make align with float->float32
* make align sql float to arrow float32
---
README.md | 2 +-
datafusion/src/sql/planner.rs | 14 +++++++-------
datafusion/tests/sql.rs | 8 ++++----
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/README.md b/README.md
index 4850384..40ee668 100644
--- a/README.md
+++ b/README.md
@@ -346,7 +346,7 @@ are mapped to Arrow types according to the following table
| `SMALLINT` | `Int16` |
| `INT` | `Int32` |
| `BIGINT` | `Int64` |
-| `REAL` | `Float64` |
+| `REAL` | `Float32` |
| `DOUBLE` | `Float64` |
| `BOOLEAN` | `Boolean` |
| `DATE` | `Date32` |
diff --git a/datafusion/src/sql/planner.rs b/datafusion/src/sql/planner.rs
index 0f9a8c0..22ddd48 100644
--- a/datafusion/src/sql/planner.rs
+++ b/datafusion/src/sql/planner.rs
@@ -366,9 +366,9 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
/// Maps the SQL type to the corresponding Arrow `DataType`
fn make_data_type(&self, sql_type: &SQLDataType) -> Result<DataType> {
match sql_type {
- SQLDataType::BigInt(_display) => Ok(DataType::Int64),
- SQLDataType::Int(_display) => Ok(DataType::Int32),
- SQLDataType::SmallInt(_display) => Ok(DataType::Int16),
+ SQLDataType::BigInt(_) => Ok(DataType::Int64),
+ SQLDataType::Int(_) => Ok(DataType::Int32),
+ SQLDataType::SmallInt(_) => Ok(DataType::Int16),
SQLDataType::Char(_) | SQLDataType::Varchar(_) | SQLDataType::Text => {
Ok(DataType::Utf8)
}
@@ -1989,10 +1989,10 @@ fn extract_possible_join_keys(
pub fn convert_data_type(sql: &SQLDataType) -> Result<DataType> {
match sql {
SQLDataType::Boolean => Ok(DataType::Boolean),
- SQLDataType::SmallInt(_display) => Ok(DataType::Int16),
- SQLDataType::Int(_display) => Ok(DataType::Int32),
- SQLDataType::BigInt(_display) => Ok(DataType::Int64),
- SQLDataType::Float(_) => Ok(DataType::Float64),
+ SQLDataType::SmallInt(_) => Ok(DataType::Int16),
+ SQLDataType::Int(_) => Ok(DataType::Int32),
+ SQLDataType::BigInt(_) => Ok(DataType::Int64),
+ SQLDataType::Float(_) => Ok(DataType::Float32),
SQLDataType::Real => Ok(DataType::Float32),
SQLDataType::Double => Ok(DataType::Float64),
SQLDataType::Char(_) | SQLDataType::Varchar(_) => Ok(DataType::Utf8),
diff --git a/datafusion/tests/sql.rs b/datafusion/tests/sql.rs
index 1dbc90d..136e4f3 100644
--- a/datafusion/tests/sql.rs
+++ b/datafusion/tests/sql.rs
@@ -1659,10 +1659,10 @@ async fn csv_query_cast() -> Result<()> {
let expected = vec![
"+-----------------------------------------+",
- "| CAST(aggregate_test_100.c12 AS Float64) |",
+ "| CAST(aggregate_test_100.c12 AS Float32) |",
"+-----------------------------------------+",
- "| 0.39144436569161134 |",
- "| 0.38870280983958583 |",
+ "| 0.39144436 |",
+ "| 0.3887028 |",
"+-----------------------------------------+",
];
@@ -1680,7 +1680,7 @@ async fn csv_query_cast_literal() -> Result<()> {
let expected = vec![
"+--------------------+---------------------------+",
- "| c12 | CAST(Int64(1) AS Float64) |",
+ "| c12 | CAST(Int64(1) AS Float32) |",
"+--------------------+---------------------------+",
"| 0.9294097332465232 | 1 |",
"| 0.3114712539863804 | 1 |",