ISSUES-2906 support join for table function

This commit is contained in:
zhang2014 2018-08-24 15:40:09 +08:00
parent 83ceeca199
commit cdc4c65adc
2 changed files with 8 additions and 3 deletions

View File

@ -669,7 +669,8 @@ static std::shared_ptr<InterpreterSelectWithUnionQuery> interpretSubquery(
/// get columns list for target table
if (function)
{
const auto & storage = const_cast<Context *>(&context)->executeTableFunction(table_expression);
auto query_context = const_cast<Context *>(&context.getQueryContext());
const auto & storage = query_context->executeTableFunction(table_expression);
columns = storage->getColumns().ordinary;
select_query->addTableFunction(*const_cast<ASTPtr *>(&table_expression));
}
@ -2467,7 +2468,8 @@ NamesAndTypesList ExpressionAnalyzer::AnalyzedJoin::getColumnsFromJoinedTable(co
else if (table_expression.table_function)
{
const auto table_function = table_expression.table_function;
const auto join_storage = const_cast<Context *>(&context.getQueryContext())->executeTableFunction(table_function);
auto query_context = const_cast<Context *>(&context.getQueryContext());
const auto & join_storage = query_context->executeTableFunction(table_function);
nested_result_sample = join_storage->getSampleBlockNonMaterialized();
}
else if (table_expression.database_and_table_name)

View File

@ -351,7 +351,10 @@ ASTs PredicateExpressionsOptimizer::evaluateAsterisk(ASTSelectQuery * select_que
StoragePtr storage;
if (table_expression->table_function)
storage = const_cast<Context &>(context).executeTableFunction(table_expression->table_function);
{
auto query_context = const_cast<Context *>(&context.getQueryContext());
storage = query_context->executeTableFunction(table_expression->table_function);
}
else if (table_expression->database_and_table_name)
{
const auto database_and_table_ast = static_cast<ASTIdentifier*>(table_expression->database_and_table_name.get());