mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Merge pull request #67774 from azat/fix-replace-modifier-format
Fix REPLACE modifier formatting (forbid omitting brackets)
This commit is contained in:
commit
809d73d739
@ -323,9 +323,7 @@ void ASTColumnsReplaceTransformer::formatImpl(const FormatSettings & settings, F
|
|||||||
{
|
{
|
||||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << "REPLACE" << (is_strict ? " STRICT " : " ") << (settings.hilite ? hilite_none : "");
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << "REPLACE" << (is_strict ? " STRICT " : " ") << (settings.hilite ? hilite_none : "");
|
||||||
|
|
||||||
if (children.size() > 1)
|
|
||||||
settings.ostr << "(";
|
settings.ostr << "(";
|
||||||
|
|
||||||
for (ASTs::const_iterator it = children.begin(); it != children.end(); ++it)
|
for (ASTs::const_iterator it = children.begin(); it != children.end(); ++it)
|
||||||
{
|
{
|
||||||
if (it != children.begin())
|
if (it != children.begin())
|
||||||
@ -333,8 +331,6 @@ void ASTColumnsReplaceTransformer::formatImpl(const FormatSettings & settings, F
|
|||||||
|
|
||||||
(*it)->formatImpl(settings, state, frame);
|
(*it)->formatImpl(settings, state, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (children.size() > 1)
|
|
||||||
settings.ostr << ")";
|
settings.ostr << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
CREATE VIEW default.my_view\n(\n `Id` UInt32,\n `Object.Key` Array(UInt16),\n `Object.Value` Array(String)\n)\nAS SELECT * REPLACE arrayMap(x -> (x + 1), `Object.Key`) AS `Object.Key`\nFROM default.my_table
|
CREATE VIEW default.my_view\n(\n `Id` UInt32,\n `Object.Key` Array(UInt16),\n `Object.Value` Array(String)\n)\nAS SELECT * REPLACE (arrayMap(x -> (x + 1), `Object.Key`) AS `Object.Key`)\nFROM default.my_table
|
||||||
|
16
tests/queries/0_stateless/03220_replace_formatting.reference
Normal file
16
tests/queries/0_stateless/03220_replace_formatting.reference
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
SELECT * REPLACE ((1 / 3) / 3 AS dummy)
|
||||||
|
SELECT * REPLACE ((1 / 3) / 3 AS dummy)
|
||||||
|
SELECT * REPLACE STRICT (1 AS id, 2 AS value)
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
0 AS id,
|
||||||
|
1 AS value
|
||||||
|
)
|
||||||
|
SELECT * REPLACE STRICT (1 AS id, 2 AS value)
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
0 AS id,
|
||||||
|
1 AS value
|
||||||
|
)
|
14
tests/queries/0_stateless/03220_replace_formatting.sh
Executable file
14
tests/queries/0_stateless/03220_replace_formatting.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
|
# shellcheck source=../shell_config.sh
|
||||||
|
. "$CUR_DIR"/../shell_config.sh
|
||||||
|
|
||||||
|
q=$($CLICKHOUSE_FORMAT <<<"SELECT * REPLACE(1/3/3 AS dummy)")
|
||||||
|
echo "$q"
|
||||||
|
$CLICKHOUSE_FORMAT <<<"$q"
|
||||||
|
|
||||||
|
# multiple columns
|
||||||
|
q=$($CLICKHOUSE_FORMAT <<<"SELECT * REPLACE STRICT (1 AS id, 2 AS value) FROM (SELECT 0 id, 1 value)")
|
||||||
|
echo "$q"
|
||||||
|
$CLICKHOUSE_FORMAT <<<"$q"
|
Loading…
Reference in New Issue
Block a user