Merge pull request #50977 from valbok/empty-table-overrides

MaterializedMySQL: Keep parentheses for empty table overrides
This commit is contained in:
Kseniia Sumarokova 2023-06-15 12:48:04 +02:00 committed by GitHub
commit b7fbc4dd8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View File

@ -36,8 +36,6 @@ void ASTTableOverride::formatImpl(const FormatSettings & settings_, FormatState
settings.ostr << hl_keyword << "TABLE OVERRIDE " << hl_none;
ASTIdentifier(table_name).formatImpl(settings, state, frame);
}
if (!columns && (!storage || storage->children.empty()))
return;
auto override_frame = frame;
if (is_standalone)
{

View File

@ -215,7 +215,7 @@ INSTANTIATE_TEST_SUITE_P(ParserCreateDatabaseQuery, ParserTest,
},
{
"CREATE DATABASE db ENGINE=Foo TABLE OVERRIDE `tbl` (), TABLE OVERRIDE a (COLUMNS (_created DateTime MATERIALIZED now())), TABLE OVERRIDE b (PARTITION BY rand())",
"CREATE DATABASE db\nENGINE = Foo\nTABLE OVERRIDE `tbl`,\nTABLE OVERRIDE `a`\n(\n COLUMNS\n (\n `_created` DateTime MATERIALIZED now()\n )\n),\nTABLE OVERRIDE `b`\n(\n PARTITION BY rand()\n)"
"CREATE DATABASE db\nENGINE = Foo\nTABLE OVERRIDE `tbl`\n(\n\n),\nTABLE OVERRIDE `a`\n(\n COLUMNS\n (\n `_created` DateTime MATERIALIZED now()\n )\n),\nTABLE OVERRIDE `b`\n(\n PARTITION BY rand()\n)"
},
{
"CREATE DATABASE db ENGINE=MaterializeMySQL('addr:port', 'db', 'user', 'pw') TABLE OVERRIDE tbl (COLUMNS (id UUID) PARTITION BY toYYYYMM(created))",

View File

@ -2042,6 +2042,18 @@ def table_overrides(clickhouse_node, mysql_node, service_name):
f"{explain_with_table_func} {testcase[0]}"
)
clickhouse_node.query("DROP DATABASE IF EXISTS table_overrides")
# Check empty table overrides
clickhouse_node.query(
f"""
CREATE DATABASE table_overrides ENGINE=MaterializeMySQL('{service_name}:3306', 'table_overrides', 'root', 'clickhouse')
TABLE OVERRIDE t1 ()
"""
)
check_query(clickhouse_node, "SELECT count() FROM table_overrides.t1", "1001\n")
show_db = clickhouse_node.query("SHOW CREATE DATABASE table_overrides")
assert "TABLE OVERRIDE `t1`\\n(\\n\\n)" in show_db, show_db
clickhouse_node.query("DROP DATABASE IF EXISTS table_overrides")
mysql_node.query("DROP DATABASE IF EXISTS table_overrides")