Fix tests.

This commit is contained in:
Nikolai Kochetov 2019-08-09 16:37:42 +03:00
parent 3df0d66058
commit a1023bebff
6 changed files with 14 additions and 25 deletions

View File

@ -967,7 +967,7 @@ StoragePtr Context::tryRemoveExternalTable(const String & table_name)
}
StoragePtr Context::executeTableFunction(const ASTPtr & table_expression) const
StoragePtr Context::executeTableFunction(const ASTPtr & table_expression)
{
/// Slightly suboptimal.
auto hash = table_expression->getTreeHash();

View File

@ -135,7 +135,7 @@ private:
/// Thus, used in HTTP interface. If not specified - then some globally default format is used.
TableAndCreateASTs external_tables; /// Temporary tables.
StoragePtr view_source; /// Temporary StorageValues used to generate alias columns for materialized views
mutable Tables table_function_results; /// Temporary tables obtained by execution of table functions. Keyed by AST tree id.
Tables table_function_results; /// Temporary tables obtained by execution of table functions. Keyed by AST tree id.
Context * query_context = nullptr;
Context * session_context = nullptr; /// Session context or nullptr. Could be equal to this.
Context * global_context = nullptr; /// Global context. Could be equal to this.
@ -245,7 +245,7 @@ public:
void addExternalTable(const String & table_name, const StoragePtr & storage, const ASTPtr & ast = {});
StoragePtr tryRemoveExternalTable(const String & table_name);
StoragePtr executeTableFunction(const ASTPtr & table_expression) const;
StoragePtr executeTableFunction(const ASTPtr & table_expression);
void addViewSource(const StoragePtr & storage);
StoragePtr getViewSource();

View File

@ -406,6 +406,9 @@ Block InterpreterSelectQuery::getSampleBlockImpl()
{
FilterInfoPtr filter_info;
/// Need to create sets before analyzeExpressions(). Otherwise some sets for index won't be created.
query_analyzer->makeSetsForIndex();
auto analysis_result = analyzeExpressions(
getSelectQuery(),
*query_analyzer,
@ -498,24 +501,6 @@ InterpreterSelectQuery::analyzeExpressions(
{
chain.finalize();
/// Check that actions on current step are valid.
/// Now this in needed for mutations to check in mutation is valid before execute it in background.
/// Because some functions only checking correctness of constant arguments during execution,
/// but not in getReturnType method (e.g. compare date with constant string).
if (dry_run)
{
for (auto & step : chain.steps)
{
auto step_required_columns = step.actions->getRequiredColumnsWithTypes();
Block sample;
for (auto & col : step_required_columns)
sample.insert({col.type->createColumn(), col.type, col.name});
step.actions->execute(sample);
}
}
if (has_prewhere)
{
const ExpressionActionsChain::Step & step = chain.steps.at(0);

View File

@ -50,7 +50,6 @@ private:
Context context;
std::vector<std::unique_ptr<InterpreterSelectQuery>> nested_interpreters;
Blocks nested_headers;
Block result_header;

View File

@ -397,7 +397,8 @@ BlockInputStreamPtr MutationsInterpreter::addStreamsForLaterStages(BlockInputStr
void MutationsInterpreter::validate()
{
prepare(/* dry_run = */ true);
Block first_stage_header = interpreter_select->getSampleBlock();
/// Do not use getSampleBlock in order to check the whole pipeline.
Block first_stage_header = interpreter_select->execute().in->getHeader();
BlockInputStreamPtr in = std::make_shared<NullBlockInputStream>(first_stage_header);
addStreamsForLaterStages(in)->getHeader();
}

View File

@ -301,8 +301,12 @@ BlockInputStreams StorageDistributed::read(
const auto & modified_query_ast = rewriteSelectQuery(
query_info.query, remote_database, remote_table, remote_table_function_ptr);
Block header = materializeBlock(
InterpreterSelectQuery(query_info.query, context, SelectQueryOptions(processed_stage)).getSampleBlock());
Block header =
InterpreterSelectQuery(query_info.query, context, SelectQueryOptions(processed_stage)).getSampleBlock();
for (auto & col : header)
if (isColumnConst(*col.column))
col.column = col.type->createColumn();
ClusterProxy::SelectStreamFactory select_stream_factory = remote_table_function_ptr
? ClusterProxy::SelectStreamFactory(