ClickHouse/tests/integration/test_explain_estimates/test.py

26 lines
1011 B
Python
Raw Normal View History

2021-07-09 14:26:08 +00:00
import pytest
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
node1 = cluster.add_instance('instance')
@pytest.fixture(scope="module")
def start_cluster():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
def test_explain_estimates(start_cluster):
2021-10-22 11:43:31 +00:00
node1.query("CREATE TABLE test (i Int64) ENGINE = MergeTree() ORDER BY i SETTINGS index_granularity = 16")
2021-07-14 12:16:22 +00:00
node1.query("INSERT INTO test SELECT number FROM numbers(128)")
2021-07-09 14:26:08 +00:00
node1.query("OPTIMIZE TABLE test")
2021-10-22 11:43:31 +00:00
# sum(marks) - 1 because EXPLAIN ESIMATES does not include final mark.
system_parts_result = node1.query("SELECT any(database), any(table), count() as parts, sum(rows) as rows, sum(marks)-1 as marks FROM system.parts WHERE database = 'default' AND table = 'test' and active = 1 GROUP BY (database, table)")
2021-07-10 23:14:03 +00:00
explain_estimates_result = node1.query("EXPLAIN ESTIMATE SELECT * FROM test")
2021-07-09 14:26:08 +00:00
assert(system_parts_result == explain_estimates_result)
2021-10-22 11:43:31 +00:00