alamb commented on a change in pull request #1431:
URL: https://github.com/apache/arrow-datafusion/pull/1431#discussion_r767327739



##########
File path: datafusion/src/sql/planner.rs
##########
@@ -372,7 +372,27 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
             SQLDataType::Char(_) | SQLDataType::Varchar(_) | SQLDataType::Text 
=> {
                 Ok(DataType::Utf8)
             }
-            SQLDataType::Decimal(_, _) => Ok(DataType::Float64),
+            SQLDataType::Decimal(precision, scale) => {
+                match (precision, scale) {
+                    (None, _) | (_, None) => {
+                        return Err(DataFusionError::Internal(format!(
+                            "Invalid Decimal type ({:?}), precision or scale 
can't be empty.",
+                            sql_type
+                        )));
+                    }
+                    (Some(p), Some(s)) => {
+                        // TODO add bound checker in some utils file or 
function

Review comment:
       👍 

##########
File path: datafusion/tests/sql.rs
##########
@@ -6459,3 +6481,34 @@ async fn test_select_wildcard_without_table() -> 
Result<()> {
     }
     Ok(())
 }
+
+#[tokio::test]
+async fn csv_query_with_decimal_by_sql() -> Result<()> {
+    let mut ctx = ExecutionContext::new();
+    register_simple_aggregate_csv_with_decimal_by_sql(&mut ctx).await;

Review comment:
       Nice




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to