Skip to content

Commit

Permalink
Deleted get_functions (ansible-collections#81)
Browse files Browse the repository at this point in the history
* Deleted get_functions

* Added changelogs
  • Loading branch information
aleksvagachev authored Sep 26, 2024
1 parent 49798dd commit 9bb6bff
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 58 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/3-info_get_functions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
breaking_changes:
- clickhouse_info - removed ``functions`` for collecting information of created functions. A rare and unpopular feature.
38 changes: 0 additions & 38 deletions plugins/modules/clickhouse_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,6 @@
type: dict
sample: { "readonly": "..." }
version_added: '0.4.0'
functions:
description:
- The content of the system.functions table with function names as keys.
- Works only for clickhouse-server versions >= 22.
- Does not output functions on the 'System' origin.
returned: success
type: dict
sample: { "test_function": "..." }
version_added: '0.4.0'
storage_policies:
description:
- The content of the system.storage_policies table with storage_policies names as keys.
Expand Down Expand Up @@ -635,34 +626,6 @@ def get_settings_profile_elements(module, client):
return settings_profile_elements


def get_functions(module, client):
"""Get functions.
Returns a dictionary with function names as keys.
"""
srv_version = get_server_version(module, client)
function_info = {}
if srv_version['year'] >= 22:
query = ("SELECT name, is_aggregate, case_insensitive, alias_to, "
"create_query, origin FROM system.functions "
"WHERE origin != 'System'")
result = execute_query(module, client, query)

if result == PRIV_ERR_CODE:
return {PRIV_ERR_CODE: "Not enough privileges"}

for row in result:
function_info[row[0]] = {
"is_aggregate": str(row[1]),
"case_insensitive": row[2],
"alias_to": row[3],
"create_query": row[4],
"origin": row[5],
}

return function_info


def get_storage_policies(module, client):
"""Get storage_policies.
Expand Down Expand Up @@ -763,7 +726,6 @@ def main():
'quotas': get_quotas,
'settings_profiles': get_settings_profiles,
'settings_profile_elements': get_settings_profile_elements,
'functions': get_functions,
'storage_policies': get_storage_policies,
'grants': get_all_grants,
}
Expand Down
20 changes: 0 additions & 20 deletions tests/integration/targets/clickhouse_info/tasks/initial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,3 @@
- result is not changed
- result["version"] != {}
- result["driver"]["version"] != {}

- name: Check function
when: result['version']['year'] >= 22
block:
- name: Create function
community.clickhouse.clickhouse_client:
execute: "CREATE FUNCTION linear_equation AS (x, k, b) -> k*x + b"

- name: Get info
register: result_func
community.clickhouse.clickhouse_info:
login_host: localhost
limit:
- functions

- name: Check result
ansible.builtin.assert:
that:
- result_func is not changed
- result_func["functions"] != {}

0 comments on commit 9bb6bff

Please sign in to comment.