Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/Parsers/ASTSystemQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ void ASTSystemQuery::formatImpl(WriteBuffer & ostr, const FormatSettings & setti

print_keyword("SYSTEM") << " ";
print_keyword(typeToString(type));
if (!cluster.empty())

std::unordered_set<Type> queries_with_on_cluster_at_end = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not really matter,
but 'static const' seem reasonable here.

Type::DROP_FILESYSTEM_CACHE,
Type::SYNC_FILESYSTEM_CACHE,
};

if (!queries_with_on_cluster_at_end.contains(type) && !cluster.empty())
formatOnCluster(ostr, settings);

switch (type)
Expand Down Expand Up @@ -519,6 +525,9 @@ void ASTSystemQuery::formatImpl(WriteBuffer & ostr, const FormatSettings & setti
case Type::END:
throw Exception(ErrorCodes::LOGICAL_ERROR, "Unknown SYSTEM command");
}

if (queries_with_on_cluster_at_end.contains(type) && !cluster.empty())
formatOnCluster(ostr, settings);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
localhost 9000 0 0 0
localhost 9000 0 0 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Tags: no-fasttest, no-parallel, no-object-storage, no-random-settings

# set -x

CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh


disk_name="${CLICKHOUSE_TEST_UNIQUE_NAME}"
$CLICKHOUSE_CLIENT -m --query """
DROP TABLE IF EXISTS test;
CREATE TABLE test (a Int32, b String)
ENGINE = MergeTree() ORDER BY tuple()
SETTINGS disk = disk(name = '$disk_name', type = cache, max_size = '100Ki', path = ${CLICKHOUSE_TEST_UNIQUE_NAME}, disk = s3_disk);
INSERT INTO test SELECT 1, 'test';
"""

$CLICKHOUSE_CLIENT --query """
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offtopic: Huh TIL this kind of strings is used in shell queries is used in ClickHouse. Three double quotes are not actually supported in bash. Effectively it creates an empty line, then appends a "multi-line" string (in quotes because the newline is replaced with a space), then appends another empty line here.

So it's effectively the same as writing

$CLICKHOUSE_CLIENT --query "
SYSTEM SYNC FILESYSTEM CACHE '$disk_name' ON CLUSTER 'test_shard_localhost';
"

No need to change anything, though. I can see it's used quite a lot in those tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have copied part of code from other test with triple quotas. Try to do not forgive this next time.
Thanks!

SYSTEM SYNC FILESYSTEM CACHE '$disk_name' ON CLUSTER 'test_shard_localhost';
"""

$CLICKHOUSE_CLIENT --query """
SYSTEM DROP FILESYSTEM CACHE '$disk_name' ON CLUSTER 'test_shard_localhost';
"""

$CLICKHOUSE_CLIENT --query """
DROP TABLE IF EXISTS test;
"""
Loading