Skip to content

Commit

Permalink
ref(admin): Allow clusterAllReplicas in system queries
Browse files Browse the repository at this point in the history
This function is very handy for debugging, since it allows aggregating across all nodes in a single
query.
  • Loading branch information
evanh committed Dec 5, 2024
1 parent 95b371b commit 9d2646e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions snuba/admin/clickhouse/system_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,11 @@ def is_query_using_only_system_tables(

for line in explain_query_tree_result.results:
line = line[0].strip()
# We don't allow table functions for now as the clickhouse analyzer isn't good enough yet to resolve those tables
if line.startswith("TABLE_FUNCTION"):
# We don't allow table functions (except clusterAllReplicas) for now as the clickhouse analyzer isn't good enough yet to resolve those tables
if (
line.startswith("TABLE_FUNCTION")
and "table_function_name: clusterAllReplicas" not in line
):
return False
if line.startswith("TABLE"):
match = re.search(r"table_name:\s*(\S+)", line, re.IGNORECASE)
Expand Down
1 change: 1 addition & 0 deletions tests/admin/test_system_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
ORDER BY
memory DESC
""",
"SELECT hostname(), avg(query_duration_ms) FROM clusterAllReplicas('default', system.query_log) GROUP BY hostname()",
],
)
@pytest.mark.clickhouse_db
Expand Down

0 comments on commit 9d2646e

Please sign in to comment.