baibaichen commented on PR #6383: URL: https://github.com/apache/incubator-gluten/pull/6383#issuecomment-2220288766
在 https://github.com/ClickHouse/ClickHouse/pull/54881 之前,`tuple` 函数创建的 `DataTypeTuple` 其 `haveExplicitNames` 为 `false`,之后为 `true`。当我们把 `tuple1` cast 成 `tuple2` 时,Clickhouse 的逻辑如下: ``` c++ //see FunctionsConversion.cpp if (from_type->haveExplicitNames() && to_type->haveExplicitNames()){ // 根据 name 来查找对应的列 } else { // 根据索引来查找对应的列 } ``` 对于下面的 SQL: ```sql create table test (i1 int , i2 int) stored as parquet; select named_struct('a', i1, 'b', i2) from test where i1 > 0; ``` 实现中会有如下的 `cast`: | from_type | to_type | | ------------------------------------------------------------ | --------------------------------------------- | | 由 `tuple` 函数创建,注意条件 `i1 > 0` ,所以 `i1` 是 `notnull` | 上层指定的返回类型 | | `Tuple(i1 Int64, i2 Nullable(Int64))` | `Tuple(a Nullable(Int64), b Nullable(Int64))` | 此时,如果 `from_type->haveExplicitNames()` 为真,则无法根据列名找到对应的列,返回只为 `null` 。当前 fix 的方法是将 `enable_named_columns_in_function_tuple` 设置为 false。 新增 `TEST(Clickhouse, PR54881)` -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
