2018-11-02 15:54:36 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
|
|
|
|
2018-11-27 12:42:11 +00:00
|
|
|
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
|
|
|
|
2020-09-16 04:26:10 +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()
|
|
|
|
|
2018-11-06 10:11:37 +00:00
|
|
|
for node in (node1, node2):
|
|
|
|
node.query('''
|
|
|
|
CREATE TABLE local_test (
|
2018-11-02 15:54:36 +00:00
|
|
|
t UInt64,
|
2018-11-27 12:42:11 +00:00
|
|
|
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-06 10:11:37 +00:00
|
|
|
''')
|
2018-11-02 15:54:36 +00:00
|
|
|
|
2018-11-06 10:11:37 +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-06 10:11:37 +00:00
|
|
|
''')
|
2018-11-02 15:54:36 +00:00
|
|
|
|
|
|
|
yield cluster
|
|
|
|
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
2020-09-16 04:26:10 +00:00
|
|
|
|
2018-11-02 15:54:36 +00:00
|
|
|
def test(started_cluster):
|
2018-11-27 12:42:11 +00:00
|
|
|
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')")
|
2020-09-16 04:26:10 +00:00
|
|
|
assert node1.query(
|
|
|
|
"SELECT col1, col2 FROM dist_test WHERE (t < 3600000) AND (col1 = 'foo') ORDER BY t ASC") == "foo\tbar\n"
|