Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clickhouse_client: add testing for querying more data types #36

Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
- name: The system.users table contain UUID value
register: result
community.clickhouse.clickhouse_client:
execute: SELECT id FROM system.users LIMIT 1

- name: Check the result
ansible.builtin.assert:
that:
- result.result[0] != []


- name: Create table with Decimal and DateTime columns
community.clickhouse.clickhouse_client:
execute: CREATE TABLE decimal_datetime (x Decimal(12,4), y DateTime) ENGINE = Memory

- name: Insert Decimal and DateTime
community.clickhouse.clickhouse_client:
execute: "INSERT INTO decimal_datetime VALUES ('4.01', '2019-01-01 00:00:00')"

- name: Select Decimal and DateTime
register: result
community.clickhouse.clickhouse_client:
execute: "SELECT * FROM decimal_datetime"

- name: Check the ret vals
ansible.builtin.assert:
that:
- result.result == [[4.01, '2019-01-01T00:00:00']]


- name: Create table with Map column
community.clickhouse.clickhouse_client:
execute: CREATE TABLE map (x Map(String, UInt64)) ENGINE = Memory

- name: Insert Map
community.clickhouse.clickhouse_client:
execute: "INSERT INTO map VALUES ({'a': 1, 'b': 2})"

- name: Select Map
register: result
community.clickhouse.clickhouse_client:
execute: "SELECT * FROM map"

- name: Check the ret vals
ansible.builtin.assert:
that:
- result.result[0][0]['a'] == 1

# Test version dependent features
- name: Get server version
register: srv
community.clickhouse.clickhouse_info:
limit: version


- name: Test Point column
when: srv['version']['year'] >= 23
block:

- name: Create table with Point column
community.clickhouse.clickhouse_client:
execute: CREATE TABLE geo_point (p Point) ENGINE = Memory

- name: Insert Point
community.clickhouse.clickhouse_client:
execute: "INSERT INTO geo_point VALUES ((10, 10))"

- name: Select Point
register: result
community.clickhouse.clickhouse_client:
execute: "SELECT * FROM geo_point"

- name: Check the ret vals
ansible.builtin.assert:
that:
- result.result == [[[10, 10]]]
68 changes: 0 additions & 68 deletions tests/integration/targets/clickhouse_client/tasks/initial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,71 +71,3 @@
ansible.builtin.assert:
that:
- result.result == [["one"], ["two"], ["three"]]


- name: The system.users table contain UUID value
register: result
community.clickhouse.clickhouse_client:
execute: SELECT id FROM system.users LIMIT 1

- name: Check the result
ansible.builtin.assert:
that:
- result.result[0] != []


- name: Create table with Decimal and DateTime columns
community.clickhouse.clickhouse_client:
execute: CREATE TABLE decimal_datetime (x Decimal(12,4), y DateTime) ENGINE = Memory

- name: Insert Decimal and DateTime
community.clickhouse.clickhouse_client:
execute: "INSERT INTO decimal_datetime VALUES ('4.01', '2019-01-01 00:00:00')"

- name: Select Decimal and DateTime
register: result
community.clickhouse.clickhouse_client:
execute: "SELECT * FROM decimal_datetime"

- name: Check the ret vals
ansible.builtin.assert:
that:
- result.result == [[4.01, '2019-01-01T00:00:00']]


- name: Create table with Map column
community.clickhouse.clickhouse_client:
execute: CREATE TABLE map (x Map(String, UInt64)) ENGINE = Memory

- name: Insert Map
community.clickhouse.clickhouse_client:
execute: "INSERT INTO map VALUES ({'a': 1, 'b': 2})"

- name: Select Map
register: result
community.clickhouse.clickhouse_client:
execute: "SELECT * FROM map"

- name: Check the ret vals
ansible.builtin.assert:
that:
- result.result[0][0]['a'] == 1


- name: Create table with IPv4 and IPv6 columns
community.clickhouse.clickhouse_client:
execute: CREATE TABLE ip (v4 IPv4, v6 IPv6) ENGINE = Memory

- name: Insert IPv4 and IPv6
community.clickhouse.clickhouse_client:
execute: "INSERT INTO ip VALUES ('192.168.0.1', '001:44c8:129:2632:33:0:252:2')"

- name: Select IPv4 and IPv6
register: result
community.clickhouse.clickhouse_client:
execute: "SELECT * FROM ip"

- name: Check the ret vals
ansible.builtin.assert:
that:
- result.result == [["192.168.0.1", "1:44c8:129:2632:33:0:252:2"]]
3 changes: 3 additions & 0 deletions tests/integration/targets/clickhouse_client/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@

# Initial CI tests of clickhouse_client module
- import_tasks: initial.yml

# File to test querying tables storing different data types
- import_tasks: data_types.yml
Loading