-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
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,
];
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels