Skip to content

Commit

Permalink
ClickHouse: --limit option for 'mutation list' command (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Burmak authored Sep 28, 2023
1 parent 5f0488e commit 364f5f0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ch_tools/chadmin/cli/mutation_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ def get_mutation(ctx, mutation, last):
is_flag=True,
help="Get mutations from all hosts in the cluster.",
)
@option(
"-l", "--limit", type=int, help="Limit the max number of objects in the output."
)
@pass_context
def list_mutations(ctx, is_done, command_pattern, on_cluster):
def list_mutations(ctx, is_done, command_pattern, on_cluster, limit):
"""List mutations."""
cluster = get_cluster_name(ctx) if on_cluster else None
query = """
Expand Down Expand Up @@ -86,13 +89,17 @@ def list_mutations(ctx, is_done, command_pattern, on_cluster):
{% if command_pattern %}
AND command ILIKE '{{ command_pattern }}'
{% endif %}
{% if limit -%}
LIMIT {{ limit }}
{% endif -%}
"""
response = execute_query(
ctx,
query,
is_done=is_done,
command_pattern=command_pattern,
cluster=cluster,
limit=limit,
format_="Vertical",
)
print(response)
Expand Down

0 comments on commit 364f5f0

Please sign in to comment.