mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 11:02:08 +00:00
Show MaterializeMySQL tables in system.parts
This commit is contained in:
parent
ef72ba7349
commit
bedc472bb0
@ -7,6 +7,7 @@
|
|||||||
#include <DataTypes/DataTypeDateTime.h>
|
#include <DataTypes/DataTypeDateTime.h>
|
||||||
#include <DataTypes/DataTypeDate.h>
|
#include <DataTypes/DataTypeDate.h>
|
||||||
#include <Storages/MergeTree/MergeTreeData.h>
|
#include <Storages/MergeTree/MergeTreeData.h>
|
||||||
|
#include <Storages/StorageMaterializeMySQL.h>
|
||||||
#include <Storages/VirtualColumnUtils.h>
|
#include <Storages/VirtualColumnUtils.h>
|
||||||
#include <Access/ContextAccess.h>
|
#include <Access/ContextAccess.h>
|
||||||
#include <Databases/IDatabase.h>
|
#include <Databases/IDatabase.h>
|
||||||
@ -119,6 +120,13 @@ StoragesInfoStream::StoragesInfoStream(const SelectQueryInfo & query_info, const
|
|||||||
|
|
||||||
String engine_name = storage->getName();
|
String engine_name = storage->getName();
|
||||||
|
|
||||||
|
#if USE_MYSQL
|
||||||
|
if (auto * proxy = dynamic_cast<StorageMaterializeMySQL *>(storage.get()))
|
||||||
|
{
|
||||||
|
auto nested = proxy->getNested();
|
||||||
|
storage.swap(nested);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (!dynamic_cast<MergeTreeData *>(storage.get()))
|
if (!dynamic_cast<MergeTreeData *>(storage.get()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -733,7 +733,6 @@ def clickhouse_killed_while_insert(clickhouse_node, mysql_node, service_name):
|
|||||||
mysql_node.query("DROP DATABASE kill_clickhouse_while_insert")
|
mysql_node.query("DROP DATABASE kill_clickhouse_while_insert")
|
||||||
clickhouse_node.query("DROP DATABASE kill_clickhouse_while_insert")
|
clickhouse_node.query("DROP DATABASE kill_clickhouse_while_insert")
|
||||||
|
|
||||||
|
|
||||||
def utf8mb4_test(clickhouse_node, mysql_node, service_name):
|
def utf8mb4_test(clickhouse_node, mysql_node, service_name):
|
||||||
mysql_node.query("DROP DATABASE IF EXISTS utf8mb4_test")
|
mysql_node.query("DROP DATABASE IF EXISTS utf8mb4_test")
|
||||||
clickhouse_node.query("DROP DATABASE IF EXISTS utf8mb4_test")
|
clickhouse_node.query("DROP DATABASE IF EXISTS utf8mb4_test")
|
||||||
@ -743,3 +742,17 @@ def utf8mb4_test(clickhouse_node, mysql_node, service_name):
|
|||||||
clickhouse_node.query("CREATE DATABASE utf8mb4_test ENGINE = MaterializeMySQL('{}:3306', 'utf8mb4_test', 'root', 'clickhouse')".format(service_name))
|
clickhouse_node.query("CREATE DATABASE utf8mb4_test ENGINE = MaterializeMySQL('{}:3306', 'utf8mb4_test', 'root', 'clickhouse')".format(service_name))
|
||||||
check_query(clickhouse_node, "SELECT id, name FROM utf8mb4_test.test ORDER BY id", "1\t\U0001F984\n2\t\u2601\n")
|
check_query(clickhouse_node, "SELECT id, name FROM utf8mb4_test.test ORDER BY id", "1\t\U0001F984\n2\t\u2601\n")
|
||||||
|
|
||||||
|
def system_parts_test(clickhouse_node, mysql_node, service_name):
|
||||||
|
mysql_node.query("DROP DATABASE IF EXISTS system_parts_test")
|
||||||
|
clickhouse_node.query("DROP DATABASE IF EXISTS system_parts_test")
|
||||||
|
mysql_node.query("CREATE DATABASE system_parts_test")
|
||||||
|
mysql_node.query("CREATE TABLE system_parts_test.test ( `id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB;")
|
||||||
|
mysql_node.query("INSERT INTO system_parts_test.test VALUES(1),(2),(3)")
|
||||||
|
def check_active_parts(num):
|
||||||
|
check_query(clickhouse_node, "SELECT count() FROM system.parts WHERE database = 'system_parts_test' AND table = 'test' AND active = 1", "{}\n".format(num))
|
||||||
|
clickhouse_node.query("CREATE DATABASE system_parts_test ENGINE = MaterializeMySQL('{}:3306', 'system_parts_test', 'root', 'clickhouse')".format(service_name))
|
||||||
|
check_active_parts(1)
|
||||||
|
mysql_node.query("INSERT INTO system_parts_test.test VALUES(4),(5),(6)")
|
||||||
|
check_active_parts(2)
|
||||||
|
clickhouse_node.query("OPTIMIZE TABLE system_parts_test.test")
|
||||||
|
check_active_parts(1)
|
||||||
|
@ -233,3 +233,7 @@ def test_clickhouse_killed_while_insert_8_0(started_cluster, started_mysql_8_0,
|
|||||||
def test_utf8mb4(started_cluster, started_mysql_8_0, started_mysql_5_7, clickhouse_node):
|
def test_utf8mb4(started_cluster, started_mysql_8_0, started_mysql_5_7, clickhouse_node):
|
||||||
materialize_with_ddl.utf8mb4_test(clickhouse_node, started_mysql_5_7, "mysql1")
|
materialize_with_ddl.utf8mb4_test(clickhouse_node, started_mysql_5_7, "mysql1")
|
||||||
materialize_with_ddl.utf8mb4_test(clickhouse_node, started_mysql_8_0, "mysql8_0")
|
materialize_with_ddl.utf8mb4_test(clickhouse_node, started_mysql_8_0, "mysql8_0")
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(('clickhouse_node'), [node_db_ordinary, node_db_ordinary])
|
||||||
|
def test_system_parts_table(started_cluster, started_mysql_8_0, clickhouse_node):
|
||||||
|
materialize_with_ddl.system_parts_test(clickhouse_node, started_mysql_8_0, "mysql8_0")
|
||||||
|
Loading…
Reference in New Issue
Block a user