yukkit opened a new issue, #8118:
URL: https://github.com/apache/arrow-datafusion/issues/8118

   When I construct the structure through the function `struct`, my original 
data type is changed. I don't know if this is a bug or an expected design, but 
I think a better way is to retain the original type
   
   **To Reproduce**
   
   ```
   CREATE TABLE values(
       c0 INT,
       c1 String,
       c2 String
   ) AS VALUES
     (1, 'a', 'a'),
     (2, 'b', 'b'),
     (3, 'c', 'c');
   
   explain verbose select struct(c0, c1, c2) from VALUES;
   ```
   
   ```
   
+------------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
   | plan_type                                                  | plan          
                                                                                
           |
   
+------------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
   | initial_logical_plan                                       | Projection: 
struct(values.c0, values.c1, values.c2)                                         
             |
   |                                                            |   TableScan: 
values                                                                          
            |
   | logical_plan after inline_table_scan                       | SAME TEXT AS 
ABOVE                                                                           
            |
   | logical_plan after type_coercion                           | Projection: 
struct(CAST(values.c0 AS Utf8), values.c1, values.c2)                           
             |
   |                                                            |   TableScan: 
values                                                                          
            |
   | logical_plan after count_wildcard_rule                     | SAME TEXT AS 
ABOVE                                                                           
            |
   | analyzed_logical_plan                                      | SAME TEXT AS 
ABOVE  
   ```
   
   I see AnalyzerRule `type_coercion` cast `values.c0` to `values.c0 AS Utf8`.
   
   I also have some questions, why struct only supports the following types? 
@Ted-Jiang  My idea is that struct can support any type. Is it possible to use 
TypeSignature::VariadicAny type of function signature?
   ```
   /// Currently supported types by the struct function.
   pub static SUPPORTED_STRUCT_TYPES: &[DataType] = &[
       DataType::Boolean,
       DataType::UInt8,
       DataType::UInt16,
       DataType::UInt32,
       DataType::UInt64,
       DataType::Int8,
       DataType::Int16,
       DataType::Int32,
       DataType::Int64,
       DataType::Float32,
       DataType::Float64,
       DataType::Utf8,
       DataType::LargeUtf8,
   ];
   ```


-- 
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