dbms: fixed error with JOINs [#METR-14847].

This commit is contained in:
Alexey Milovidov 2015-02-01 10:20:33 +03:00
parent 22b9ecfdea
commit 5271a45625
4 changed files with 5 additions and 10 deletions

View File

@ -45,13 +45,6 @@ typedef std::unordered_map<String, SubqueryForSet> SubqueriesForSets;
class ExpressionAnalyzer : private boost::noncopyable
{
public:
ExpressionAnalyzer(const ASTPtr & ast_, const Context & context_, size_t subquery_depth_ = 0, bool do_global_ = false)
: ast(ast_), context(context_), settings(context.getSettings()),
subquery_depth(subquery_depth_), columns(context.getColumns()), storage(getTable()), do_global(do_global_)
{
init();
}
ExpressionAnalyzer(const ASTPtr & ast_, const Context & context_, StoragePtr storage_, size_t subquery_depth_ = 0, bool do_global_ = false)
: ast(ast_), context(context_), settings(context.getSettings()),
subquery_depth(subquery_depth_), columns(context.getColumns()), storage(storage_ ? storage_ : getTable()), do_global(do_global_)

View File

@ -634,7 +634,7 @@ void ExpressionAnalyzer::addExternalStorage(ASTPtr & subquery_or_table_name)
}
}
SharedPtr<InterpreterSelectQuery> interpreter = interpretSubquery(subquery_or_table_name, context, subquery_depth);
SharedPtr<InterpreterSelectQuery> interpreter = interpretSubquery(subquery_or_table_name, context, subquery_depth + 1);
Block sample = interpreter->getSampleBlock();
NamesAndTypesListPtr columns = new NamesAndTypesList(sample.getColumnsList());
@ -1837,8 +1837,8 @@ void ExpressionAnalyzer::collectJoinedColumns(NameSet & joined_columns, NamesAnd
}
else if (typeid_cast<const ASTSubquery *>(node.table.get()))
{
const auto & table = node.table->children.at(0);
nested_result_sample = ExpressionAnalyzer(table, context, subquery_depth + 1).getSelectSampleBlock();
const auto & subquery = node.table->children.at(0);
nested_result_sample = InterpreterSelectQuery(subquery, context, QueryProcessingStage::Complete, subquery_depth + 1).getSampleBlock();
}
auto & keys = typeid_cast<ASTExpressionList &>(*node.using_expr_list);

View File

@ -0,0 +1 @@
SELECT 1 AS k ANY LEFT JOIN (SELECT k FROM (SELECT 1 AS k, 2 AS x)) USING k;