2020-03-11 13:36:33 +00:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include <Interpreters/QueryNormalizer.h>
|
|
|
|
#include <Parsers/IAST.h>
|
|
|
|
#include <Parsers/queryToString.h>
|
|
|
|
#include <Parsers/ExpressionListParsers.h>
|
|
|
|
#include <Parsers/parseQuery.h>
|
|
|
|
|
|
|
|
using namespace DB;
|
|
|
|
|
|
|
|
TEST(QueryNormalizer, SimpleCycleAlias)
|
|
|
|
{
|
|
|
|
String query = "a as b, b as a";
|
|
|
|
ParserExpressionList parser(false);
|
2020-04-15 20:28:05 +00:00
|
|
|
ASTPtr ast = parseQuery(parser, query, 0, 0);
|
2020-03-11 13:36:33 +00:00
|
|
|
|
|
|
|
Aliases aliases;
|
2020-04-15 20:28:05 +00:00
|
|
|
aliases["a"] = parseQuery(parser, "b as a", 0, 0)->children[0];
|
|
|
|
aliases["b"] = parseQuery(parser, "a as b", 0, 0)->children[0];
|
2020-03-11 13:36:33 +00:00
|
|
|
|
|
|
|
Settings settings;
|
|
|
|
QueryNormalizer::Data normalizer_data(aliases, settings);
|
|
|
|
EXPECT_THROW(QueryNormalizer(normalizer_data).visit(ast), Exception);
|
|
|
|
}
|