mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
move CREATE query rewriting for views to Interpreter [#CLICKHOUSE-2]
This commit is contained in:
parent
75c65c7b59
commit
1f76900500
@ -488,6 +488,7 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create)
|
||||
/// For `view` type tables, you may need `sample_block` to get the columns.
|
||||
if (create.select && (!create.attach || (!create.columns && (create.is_view || create.is_materialized_view))))
|
||||
{
|
||||
create.select->setDatabaseIfNeeded(database_name);
|
||||
interpreter_select = std::make_unique<InterpreterSelectQuery>(create.select->ptr(), context);
|
||||
as_select_sample = interpreter_select->getSampleBlock();
|
||||
}
|
||||
|
@ -72,9 +72,6 @@ StorageMaterializedView::StorageMaterializedView(
|
||||
if (!query.inner_storage)
|
||||
throw Exception("ENGINE of MaterializedView should be specified explicitly", ErrorCodes::INCORRECT_QUERY);
|
||||
|
||||
/// If the internal query does not specify a database, retrieve it from the context and write it to the query.
|
||||
query.select->setDatabaseIfNeeded(database_name);
|
||||
|
||||
extractDependentTable(*query.select, select_database_name, select_table_name);
|
||||
|
||||
if (!select_table_name.empty())
|
||||
|
@ -12,7 +12,7 @@ namespace DB
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int LOGICAL_ERROR;
|
||||
extern const int INCORRECT_QUERY;
|
||||
}
|
||||
|
||||
|
||||
@ -28,8 +28,9 @@ StorageView::StorageView(
|
||||
: IStorage{materialized_columns_, alias_columns_, column_defaults_}, table_name(table_name_),
|
||||
database_name(database_name_), context(context_), columns(columns_)
|
||||
{
|
||||
/// If the internal query does not specify a database, retrieve it from the context and write it to the query.
|
||||
query.select->setDatabaseIfNeeded(database_name);
|
||||
if (!query.select)
|
||||
throw Exception("SELECT query is not specified for " + getName(), ErrorCodes::INCORRECT_QUERY);
|
||||
|
||||
inner_query = query.select->ptr();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user