ClickHouse/tests/integration/test_version_update/test.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
2.5 KiB
Python
Raw Normal View History

2021-05-17 14:29:32 +00:00
import pytest
2024-09-27 10:19:39 +00:00
from helpers.cluster import CLICKHOUSE_CI_MIN_TESTED_VERSION, ClickHouseCluster
2021-05-17 14:29:32 +00:00
cluster = ClickHouseCluster(__file__)
2021-05-30 13:57:30 +00:00
2021-11-27 09:40:46 +00:00
node1 = cluster.add_instance("node1", stay_alive=True)
2021-05-30 13:57:30 +00:00
2021-05-31 14:44:57 +00:00
node2 = cluster.add_instance(
"node2",
with_zookeeper=True,
2024-02-26 12:45:20 +00:00
image="clickhouse/clickhouse-server",
tag=CLICKHOUSE_CI_MIN_TESTED_VERSION,
2021-05-31 14:44:57 +00:00
with_installed_binary=True,
stay_alive=True,
)
2021-05-31 14:44:57 +00:00
def insert_data(node, table_name="test_table", n=1, col2=1):
node.query(
""" INSERT INTO {}
SELECT toDateTime(NOW()), {},
sumMapState(arrayMap(i -> 1, range(300)), arrayMap(i -> 1, range(300)))
FROM numbers({});""".format(
table_name, col2, n
)
)
2021-05-30 22:54:42 +00:00
2021-05-31 14:44:57 +00:00
def create_table(node, name="test_table", version=None):
node.query("DROP TABLE IF EXISTS {};".format(name))
if version is None:
node.query(
"""
CREATE TABLE {}
(
`col1` DateTime,
`col2` Int64,
`col3` AggregateFunction(sumMap, Array(UInt8), Array(UInt8))
)
ENGINE = AggregatingMergeTree() ORDER BY (col1, col2) """.format(
name
)
)
2021-05-31 14:44:57 +00:00
else:
node.query(
"""
CREATE TABLE {}
(
`col1` DateTime,
`col2` Int64,
`col3` AggregateFunction({}, sumMap, Array(UInt8), Array(UInt8))
)
ENGINE = AggregatingMergeTree() ORDER BY (col1, col2) """.format(
name, version
)
)
2021-05-17 14:29:32 +00:00
@pytest.fixture(scope="module")
def start_cluster():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
2021-05-30 13:57:30 +00:00
def test_modulo_partition_key_issue_23508(start_cluster):
2021-05-31 14:44:57 +00:00
node2.query(
"CREATE TABLE test (id Int64, v UInt64, value String) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/table1', '1', v) PARTITION BY id % 20 ORDER BY (id, v)"
)
node2.query(
"INSERT INTO test SELECT number, number, toString(number) FROM numbers(10)"
)
2021-05-30 13:57:30 +00:00
2021-05-31 14:44:57 +00:00
expected = node2.query("SELECT number, number, toString(number) FROM numbers(10)")
partition_data = node2.query(
"SELECT partition, name FROM system.parts WHERE table='test' ORDER BY partition"
)
assert expected == node2.query("SELECT * FROM test ORDER BY id")
2021-05-30 13:57:30 +00:00
2021-05-31 14:44:57 +00:00
node2.restart_with_latest_version()
2021-05-30 13:57:30 +00:00
2021-05-31 14:44:57 +00:00
assert expected == node2.query("SELECT * FROM test ORDER BY id")
assert partition_data == node2.query(
"SELECT partition, name FROM system.parts WHERE table='test' ORDER BY partition"
)