More fixes

This commit is contained in:
Raúl Marín 2024-03-05 15:30:42 +01:00
parent 06409a8aa3
commit 56e0dd0ab0
2 changed files with 19 additions and 6 deletions

View File

@ -74,12 +74,23 @@ bool ASTQueryWithOutput::resetOutputASTIfExist(IAST & ast)
/// FIXME: try to prettify this cast using `as<>()` /// FIXME: try to prettify this cast using `as<>()`
if (auto * ast_with_output = dynamic_cast<ASTQueryWithOutput *>(&ast)) if (auto * ast_with_output = dynamic_cast<ASTQueryWithOutput *>(&ast))
{ {
ast_with_output->out_file.reset(); auto remove_if_exists = [&](ASTPtr & p)
ast_with_output->format.reset(); {
ast_with_output->settings_ast.reset(); if (p)
ast_with_output->compression.reset(); {
ast_with_output->compression_level.reset(); if (auto it = std::find(ast_with_output->children.begin(), ast_with_output->children.end(), p);
ast_with_output->children.clear(); it != ast_with_output->children.end())
ast_with_output->children.erase(it);
p.reset();
}
};
remove_if_exists(ast_with_output->out_file);
remove_if_exists(ast_with_output->format);
remove_if_exists(ast_with_output->settings_ast);
remove_if_exists(ast_with_output->compression);
remove_if_exists(ast_with_output->compression_level);
return true; return true;
} }

View File

@ -136,6 +136,7 @@ bool ParserQueryWithOutput::parseImpl(Pos & pos, ASTPtr & node, Expected & expec
ParserStringLiteral compression; ParserStringLiteral compression;
if (!compression.parse(pos, query_with_output.compression, expected)) if (!compression.parse(pos, query_with_output.compression, expected))
return false; return false;
query_with_output.children.push_back(query_with_output.compression);
ParserKeyword s_compression_level("LEVEL"); ParserKeyword s_compression_level("LEVEL");
if (s_compression_level.ignore(pos, expected)) if (s_compression_level.ignore(pos, expected))
@ -143,6 +144,7 @@ bool ParserQueryWithOutput::parseImpl(Pos & pos, ASTPtr & node, Expected & expec
ParserNumber compression_level; ParserNumber compression_level;
if (!compression_level.parse(pos, query_with_output.compression_level, expected)) if (!compression_level.parse(pos, query_with_output.compression_level, expected))
return false; return false;
query_with_output.children.push_back(query_with_output.compression_level);
} }
} }