ClickHouse/tests/queries/0_stateless/03220_replace_formatting.sh
Azat Khuzhin 8bca80f4dd Fix REPLACE modifier formatting (forbid omitting brackets)
It is too tricky to verify does brackets required or not, i.e. "SELECT *
REPLACE(1/3/3 AS dummy)" will be formatted to "SELECT * REPLACE (1/3)/3 AS dummy"
which is already invalid query.

So let's simply always print them.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
v2: move the fix into correct place ASTColumnsReplaceTransformer::formatImpl() instead of ASTColumnsReplaceTransformer::Replacement::formatImpl()
2024-08-05 08:59:28 +02:00

15 lines
406 B
Bash
Executable File

#!/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"