mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Save join settings for view
This commit is contained in:
parent
ed3f89a7be
commit
701ff6d17d
@ -33,8 +33,10 @@ namespace ErrorCodes
|
||||
StorageView::StorageView(
|
||||
const StorageID & table_id_,
|
||||
const ASTCreateQuery & query,
|
||||
const ColumnsDescription & columns_)
|
||||
const ColumnsDescription & columns_,
|
||||
const Settings & settings)
|
||||
: IStorage(table_id_)
|
||||
, settings_changes{{"join_use_nulls", Field(settings.join_use_nulls)}}
|
||||
{
|
||||
StorageInMemoryMetadata storage_metadata;
|
||||
storage_metadata.setColumns(columns_);
|
||||
@ -85,7 +87,10 @@ void StorageView::read(
|
||||
current_inner_query = query_info.view_query->clone();
|
||||
}
|
||||
|
||||
InterpreterSelectWithUnionQuery interpreter(current_inner_query, context, {}, column_names);
|
||||
auto modified_context = Context::createCopy(context);
|
||||
modified_context->applySettingsChanges(settings_changes);
|
||||
|
||||
InterpreterSelectWithUnionQuery interpreter(current_inner_query, modified_context, {}, column_names);
|
||||
interpreter.buildQueryPlan(query_plan);
|
||||
|
||||
/// It's expected that the columns read from storage are not constant.
|
||||
@ -173,7 +178,7 @@ void registerStorageView(StorageFactory & factory)
|
||||
if (args.query.storage)
|
||||
throw Exception("Specifying ENGINE is not allowed for a View", ErrorCodes::INCORRECT_QUERY);
|
||||
|
||||
return StorageView::create(args.table_id, args.query, args.columns);
|
||||
return StorageView::create(args.table_id, args.query, args.columns, args.getLocalContext()->getSettingsRef());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,10 @@ protected:
|
||||
StorageView(
|
||||
const StorageID & table_id_,
|
||||
const ASTCreateQuery & query,
|
||||
const ColumnsDescription & columns_);
|
||||
const ColumnsDescription & columns_,
|
||||
const Settings & settings);
|
||||
|
||||
SettingsChanges settings_changes;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ StoragePtr TableFunctionView::executeImpl(
|
||||
const ASTPtr & /*ast_function*/, ContextPtr context, const std::string & table_name, ColumnsDescription /*cached_columns*/) const
|
||||
{
|
||||
auto columns = getActualTableStructure(context);
|
||||
auto res = StorageView::create(StorageID(getDatabaseName(), table_name), create, columns);
|
||||
auto res = StorageView::create(StorageID(getDatabaseName(), table_name), create, columns, context->getSettingsRef());
|
||||
res->startup();
|
||||
return res;
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
1 11 0
|
||||
1 12 0
|
||||
2 11 22
|
||||
2 11 23
|
||||
2 12 22
|
||||
2 12 23
|
||||
3 0 22
|
||||
3 0 23
|
16
tests/queries/0_stateless/01866_view_persist_settings.sql
Normal file
16
tests/queries/0_stateless/01866_view_persist_settings.sql
Normal file
@ -0,0 +1,16 @@
|
||||
DROP TABLE IF EXISTS some_test_view;
|
||||
|
||||
SET join_use_nulls = 0;
|
||||
|
||||
CREATE OR REPLACE VIEW some_test_view
|
||||
AS
|
||||
SELECT * FROM ( SELECT arrayJoin([1, 2]) AS a, arrayJoin([11, 12]) AS b ) AS t1
|
||||
FULL JOIN ( SELECT arrayJoin([2, 3]) AS a, arrayJoin([22, 23]) AS c ) AS t2
|
||||
USING a
|
||||
ORDER BY a;
|
||||
|
||||
SET join_use_nulls = 1;
|
||||
|
||||
SELECT * from some_test_view;
|
||||
|
||||
DROP TABLE some_test_view;
|
Loading…
Reference in New Issue
Block a user