mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
Merge pull request #55887 from ucasfl/fix-union-distinct
Fix normalize ASTSelectWithUnionQuery strip FORMAT of the query
This commit is contained in:
commit
da42f2eb0f
@ -29,7 +29,13 @@ void NormalizeSelectWithUnionQueryMatcher::getSelectsFromUnionListNode(ASTPtr as
|
||||
void NormalizeSelectWithUnionQueryMatcher::visit(ASTPtr & ast, Data & data)
|
||||
{
|
||||
if (auto * select_union = ast->as<ASTSelectWithUnionQuery>())
|
||||
{
|
||||
/// The rewrite of ASTSelectWithUnionQuery may strip the format info, so
|
||||
/// we need to keep and restore it.
|
||||
auto format = select_union->format;
|
||||
visit(*select_union, data);
|
||||
select_union->format = format;
|
||||
}
|
||||
}
|
||||
|
||||
void NormalizeSelectWithUnionQueryMatcher::visit(ASTSelectWithUnionQuery & ast, Data & data)
|
||||
|
@ -0,0 +1,7 @@
|
||||
┌─[1m1[0m─┐
|
||||
│ 1 │
|
||||
└───┘
|
||||
┌─[1ma[0m─┐
|
||||
│ 1 │
|
||||
│ 2 │
|
||||
└───┘
|
8
tests/queries/0_stateless/02896_union_distinct_http_format.sh
Executable file
8
tests/queries/0_stateless/02896_union_distinct_http_format.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
curl -d@- -sS "${CLICKHOUSE_URL}" <<< 'SELECT 1 UNION DISTINCT SELECT 1 FORMAT PrettyCompactMonoBlock'
|
||||
curl -d@- -sS "${CLICKHOUSE_URL}" <<< 'SELECT * FROM (SELECT 1 as a UNION DISTINCT SELECT 2 as a) ORDER BY a FORMAT PrettyCompactMonoBlock'
|
Loading…
Reference in New Issue
Block a user