You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
createtabletest_window_collate(c1 String, c2 String) engine=MergeTree order by c1;
insert into test_window_collate values('1', '上海');
insert into test_window_collate values('1', '北京');
insert into test_window_collate values('1', '西安');
select c2, groupArray(c2) over (partition by c1 order by c2 asc collate 'zh_Hans_CN') as res from test_window_collate order by c2 asc collate 'zh_Hans_CN';
Actual result
c2
res
北京
['上海‘, '北京']
上海
['上海‘]
西安
['上海‘, '北京', '西安']
Expected result
c2
res
北京
['北京']
上海
['北京', '上海‘]
西安
['北京', '上海‘, '西安']
Guess the cause
It's not the expected result because invalid use of collate in window functions.
Code analysis
File ParserSelectQuery.cpp
Line 164
Code if (!exp_list_for_select_clause.parse(pos, select_expression_list, expected)) The code here does not give s_order_by(Line 262) a chance to get the collate
File ExpressionAnalyzer.cpp
Line 1951
Code && !query_analyzer.hasWindow() This code causes collator not to be created
Fixed with the new analyzer which is enabled by default.
SET allow_experimental_analyzer=1;
SELECT
c2,
groupArray(c2) OVER (PARTITION BY c1 ORDER BY c2 ASC COLLATE 'zh_Hans_CN') AS res
FROM test_window_collate
ORDER BY c2 ASC COLLATE 'zh_Hans_CN'
┌─c2───┬─res────────────────────┐
1. │ 北京 │ ['北京'] │
2. │ 上海 │ ['北京','上海'] │
3. │ 西安 │ ['北京','上海','西安'] │
└──────┴────────────────────────┘
Activity
rgzntrade commentedon Dec 9, 2022
I found a way on my own and the results were as expected. I don't know if there are any potential risks.
Is there any risk in me doing this?
Close: #44039
fm4v commentedon Apr 11, 2024
Fixed with the new analyzer which is enabled by default.