Fix normalize ASTSelectWithUnionQuery strip FORMAT of the query

This commit is contained in:
flynn 2023-10-20 16:30:44 +00:00
parent 749412bfeb
commit fda36deec3
3 changed files with 17 additions and 0 deletions

View File

@ -29,7 +29,13 @@ void NormalizeSelectWithUnionQueryMatcher::getSelectsFromUnionListNode(ASTPtr as
void NormalizeSelectWithUnionQueryMatcher::visit(ASTPtr & ast, Data & data) void NormalizeSelectWithUnionQueryMatcher::visit(ASTPtr & ast, Data & data)
{ {
if (auto * select_union = ast->as<ASTSelectWithUnionQuery>()) 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); visit(*select_union, data);
select_union->format = format;
}
} }
void NormalizeSelectWithUnionQueryMatcher::visit(ASTSelectWithUnionQuery & ast, Data & data) void NormalizeSelectWithUnionQueryMatcher::visit(ASTSelectWithUnionQuery & ast, Data & data)

View File

@ -0,0 +1,4 @@
┌─1─┐
│ 1 │
│ 2 │
└───┘

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
echo 'SELECT 1 UNION DISTINCT SELECT 2 FORMAT PrettyCompactMonoBlock' | curl 'http://localhost:8123/' --data-binary @-