Skip to content

Commit

Permalink
clickhouse_client: add queriyng more types to tests (ansible-collecti…
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersson007 authored Feb 27, 2024
1 parent 9af667a commit ed30582
Showing 1 changed file with 56 additions and 3 deletions.
59 changes: 56 additions & 3 deletions tests/integration/targets/clickhouse_client/tasks/data_types.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# UUID
- name: The system.users table contain UUID value
register: result
community.clickhouse.clickhouse_client:
Expand All @@ -8,7 +9,7 @@
that:
- result.result[0] != []


# Decimal & DateTime
- 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
Expand All @@ -27,7 +28,7 @@
that:
- result.result == [[4.01, '2019-01-01T00:00:00']]


# Map
- name: Create table with Map column
community.clickhouse.clickhouse_client:
execute: CREATE TABLE map (x Map(String, UInt64)) ENGINE = Memory
Expand All @@ -46,17 +47,69 @@
that:
- result.result[0][0]['a'] == 1


# FixedString
- name: Create table with FixedString column
community.clickhouse.clickhouse_client:
execute: CREATE TABLE fixed_string (fs FixedString(2)) ENGINE = Memory

- name: Insert FixedString
community.clickhouse.clickhouse_client:
execute: "INSERT INTO fixed_string VALUES ('a')"

- name: Select FixedString
register: result
community.clickhouse.clickhouse_client:
execute: "SELECT * FROM fixed_string"

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


# Enum
- name: Create table with Enum column
community.clickhouse.clickhouse_client:
execute: "CREATE TABLE t_enum (e Enum('hello' = 1, 'world' = 2)) ENGINE = Memory"

- name: Insert Enum
community.clickhouse.clickhouse_client:
execute: "INSERT INTO t_enum VALUES ('hello'), ('world')"

- name: Select Enum
register: result
community.clickhouse.clickhouse_client:
execute: "SELECT * FROM t_enum"

- name: Check the ret vals
ansible.builtin.assert:
that:
- result.result == [['hello'], ['world']]

- name: Select Enum with cast
register: result
community.clickhouse.clickhouse_client:
execute: "SELECT CAST(e, 'Int8') FROM t_enum"

- name: Check the ret vals
ansible.builtin.assert:
that:
- result.result == [[1], [2]]


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


- name: Test Point column
- name: Types supported since version 23.*
when: srv['version']['year'] >= 23
block:

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

0 comments on commit ed30582

Please sign in to comment.