You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/28 20:58:43 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #2366: feat: Support casting to arrays to primitive type

alamb commented on code in PR #2366:
URL: https://github.com/apache/arrow-datafusion/pull/2366#discussion_r861300917


##########
datafusion/core/src/sql/planner.rs:
##########
@@ -2395,7 +2395,10 @@ pub fn convert_data_type(sql_type: &SQLDataType) -> Result<DataType> {
         SQLDataType::Float(_) => Ok(DataType::Float32),
         SQLDataType::Real => Ok(DataType::Float32),
         SQLDataType::Double => Ok(DataType::Float64),
-        SQLDataType::Char(_) | SQLDataType::Varchar(_) => Ok(DataType::Utf8),
+        SQLDataType::Char(_)
+        | SQLDataType::Varchar(_)
+        | SQLDataType::Text

Review Comment:
   This also adds support for the `TEXT` sql type, right? (not a problem, I am just validating that this was intended)



##########
datafusion/core/tests/sql/expr.rs:
##########
@@ -796,6 +796,11 @@ async fn test_regex_expressions() -> Result<()> {
 
 #[tokio::test]
 async fn test_cast_expressions() -> Result<()> {
+    test_expression!("CAST([1,2,3,4] AS INT[])", "[1, 2, 3, 4]");
+    test_expression!(
+        "CAST([1,2,3,4] AS NUMERIC(10,4)[])",

Review Comment:
   👍 
   
   I ran this test without the code change and it failed like
   
   ```
   ---- sql::expr::test_cast_expressions stdout ----
   thread 'sql::expr::test_cast_expressions' panicked at 'Creating logical plan for 'SELECT CAST([1,2,3,4] AS INT[])': NotImplemented("Unsupported SQL type Array(Int(None))")', datafusion/core/tests/sql/mod.rs:538:45
   
   ```
   
   In case anyone was curious



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org