Skip to content

Commit

Permalink
ref(admin): Allow clusterAllReplicas in system queries (#6619)
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 authored Dec 5, 2024
1 parent 95b371b commit 194c398
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 194c398

Please sign in to comment.