Merge pull request #48679 from ucasfl/scheme-infer

Make Schema inference works for CREATE AS SELECT
This commit is contained in:
pufit 2023-04-13 13:02:04 -04:00 committed by GitHub
commit a8c892f925
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 1 deletions

View File

@ -1614,6 +1614,8 @@ BlockIO InterpreterCreateQuery::fillTableIfNeeded(const ASTCreateQuery & create)
else else
insert->select = create.select->clone(); insert->select = create.select->clone();
getContext()->getQueryContext()->setInsertionTable(insert->table_id);
return InterpreterInsertQuery(insert, getContext(), return InterpreterInsertQuery(insert, getContext(),
getContext()->getSettingsRef().insert_allow_materialized_columns).execute(); getContext()->getSettingsRef().insert_allow_materialized_columns).execute();
} }

View File

@ -407,7 +407,6 @@ BlockIO InterpreterInsertQuery::execute()
auto new_context = Context::createCopy(context); auto new_context = Context::createCopy(context);
new_context->setSettings(new_settings); new_context->setSettings(new_settings);
new_context->setInsertionTable(getContext()->getInsertionTable());
auto select_query_options = SelectQueryOptions(QueryProcessingStage::Complete, 1); auto select_query_options = SelectQueryOptions(QueryProcessingStage::Complete, 1);

View File

@ -0,0 +1,7 @@
DROP TABLE IF EXISTS t;
CREATE TABLE t(n UInt32, s String) engine=Log AS SELECT * from generateRandom() limit 10;
select count() from t;
DROP TABLE t;