ClickHouse/tests/integration/test_block_structure_mismatch/test.py

64 lines
1.5 KiB
Python
Raw Normal View History

2018-11-02 15:54:36 +00:00
import pytest
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
node1 = cluster.add_instance("node1", main_configs=["configs/remote_servers.xml"])
node2 = cluster.add_instance("node2", main_configs=["configs/remote_servers.xml"])
2018-11-02 15:54:36 +00:00
# test reproducing issue https://github.com/ClickHouse/ClickHouse/issues/3162
2018-11-02 15:54:36 +00:00
@pytest.fixture(scope="module")
def started_cluster():
try:
cluster.start()
for node in (node1, node2):
node.query(
"""
CREATE TABLE local_test (
2018-11-02 15:54:36 +00:00
t UInt64,
date Date DEFAULT toDate(t/1000),
2018-11-02 15:54:36 +00:00
shard UInt64,
col1 String,
col2 String
) ENGINE = MergeTree
PARTITION BY toRelativeDayNum(date)
ORDER BY (t)
SETTINGS index_granularity=8192
"""
)
2018-11-02 15:54:36 +00:00
node.query(
"""
CREATE TABLE dist_test (
2018-11-02 15:54:36 +00:00
t UInt64,
shard UInt64,
date Date MATERIALIZED toDate(t/1000),
col1 String,
col2 String
) Engine = Distributed(testcluster, default, local_test, shard)
"""
)
2018-11-02 15:54:36 +00:00
yield cluster
finally:
cluster.shutdown()
2018-11-02 15:54:36 +00:00
def test(started_cluster):
node1.query(
"INSERT INTO local_test (t, shard, col1, col2) VALUES (1000, 0, 'x', 'y')"
)
node2.query(
"INSERT INTO local_test (t, shard, col1, col2) VALUES (1000, 1, 'foo', 'bar')"
)
assert (
node1.query(
"SELECT col1, col2 FROM dist_test WHERE (t < 3600000) AND (col1 = 'foo') ORDER BY t ASC"
)
== "foo\tbar\n"
)