Fixed ClickHouse after changing syntax.

This commit is contained in:
Vladimir Chebotarev 2019-10-16 10:32:37 +03:00
parent 7a37c4f6a9
commit 3e984609fb
2 changed files with 33 additions and 13 deletions

View File

@ -1,4 +1,5 @@
#include <Columns/Collator.h>
#include <Common/quoteString.h>
#include <Parsers/ASTTTLElement.h>
@ -8,19 +9,18 @@ namespace DB
void ASTTTLElement::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
{
children.front()->formatImpl(settings, state, frame);
if (destination_type == DestinationType::DISK) {
settings.ostr << " TO DISK ";
} else if (destination_type == DestinationType::VOLUME) {
settings.ostr << " TO VOLUME ";
} else if (destination_type == DestinationType::DELETE) {
if (destination_type == DestinationType::DISK)
{
settings.ostr << " TO DISK " << quoteString(destination_name);
}
else if (destination_type == DestinationType::VOLUME)
{
settings.ostr << " TO VOLUME " << quoteString(destination_name);
}
else if (destination_type == DestinationType::DELETE)
{
settings.ostr << " DELETE";
}
if (destination_type == DestinationType::DISK || destination_type == DestinationType::VOLUME) {
WriteBufferFromOwnString destination_name_buf;
writeQuoted(destination_name, destination_name_buf);
settings.ostr << destination_name_buf.str();
}
}
}

View File

@ -604,12 +604,32 @@ void MergeTreeData::setTTLExpressions(const ColumnsDescription::ColumnTTLs & new
if (new_ttl_table_ast)
{
auto new_ttl_table_entry = create_ttl_entry(new_ttl_table_ast);
ASTPtr new_delete_ttl_table_ast;
for (auto ttl_element_ptr : new_ttl_table_ast->children)
{
ASTTTLElement & ttl_element = static_cast<ASTTTLElement &>(*ttl_element_ptr);
if (ttl_element.destination_type == ASTTTLElement::DELETE)
{
if (new_delete_ttl_table_ast)
{
throw Exception("Too many DELETE ttls.", ErrorCodes::BAD_TTL_EXPRESSION);
}
new_delete_ttl_table_ast = ttl_element.children[0];
}
else
{
// FIXME: Read MOVE ttls.
}
}
auto new_ttl_table_entry = create_ttl_entry(new_delete_ttl_table_ast);
if (!only_check)
{
ttl_table_ast = new_ttl_table_ast;
ttl_table_ast = new_delete_ttl_table_ast;
ttl_table_entry = new_ttl_table_entry;
}
// FIXME: Apply MOVE ttls.
}
}