diff --git a/src/Storages/StorageView.cpp b/src/Storages/StorageView.cpp index 5119c5b121d..6d4fbc1dff3 100644 --- a/src/Storages/StorageView.cpp +++ b/src/Storages/StorageView.cpp @@ -86,12 +86,7 @@ void StorageView::read( current_inner_query = query_info.view_query->clone(); } - auto modified_context = Context::createCopy(context); - /// Use settings from global context, - /// because difference between settings set on VIEW creation and query execution can break queries - modified_context->setSettings(context->getGlobalContext()->getSettingsRef()); - - InterpreterSelectWithUnionQuery interpreter(current_inner_query, modified_context, {}, column_names); + InterpreterSelectWithUnionQuery interpreter(current_inner_query, context, {}, column_names); interpreter.buildQueryPlan(query_plan); /// It's expected that the columns read from storage are not constant. diff --git a/tests/queries/0_stateless/01866_view_persist_settings.reference b/tests/queries/0_stateless/01866_view_persist_settings.reference index 07c96e76875..4d7e1356807 100644 --- a/tests/queries/0_stateless/01866_view_persist_settings.reference +++ b/tests/queries/0_stateless/01866_view_persist_settings.reference @@ -1,8 +1,5 @@ join_use_nulls = 1 - -1 11 0 -2 12 22 -3 0 23 - 1 11 0 2 12 22 @@ -12,9 +9,40 @@ join_use_nulls = 1 2 12 22 3 \N 23 - -1 11 0 +1 11 \N 2 12 22 -3 0 23 +3 \N 23 +join_use_nulls = 0 +- +1 11 0 +2 12 22 +3 0 23 +- +1 11 0 +2 12 22 +3 0 23 +- +1 11 \N +2 12 22 +3 \N 23 +- +1 11 0 +2 12 22 +3 0 23 +join_use_nulls = 1 +- +- +1 11 0 +2 12 22 +3 0 23 +- +1 11 \N +2 12 22 +3 \N 23 +- +1 11 \N +2 12 22 +3 \N 23 join_use_nulls = 0 - 1 11 0 diff --git a/tests/queries/0_stateless/01866_view_persist_settings.sql b/tests/queries/0_stateless/01866_view_persist_settings.sql index 71d6c856b9b..74c94ec6369 100644 --- a/tests/queries/0_stateless/01866_view_persist_settings.sql +++ b/tests/queries/0_stateless/01866_view_persist_settings.sql @@ -33,6 +33,19 @@ SET join_use_nulls = 1; SELECT 'join_use_nulls = 1'; +SELECT '-'; +SELECT * FROM view_no_nulls; -- { serverError 349 } +SELECT '-'; +SELECT * FROM view_no_nulls_set; +SELECT '-'; +SELECT * FROM view_nulls_set; +SELECT '-'; +SELECT * FROM view_nulls; + +SET join_use_nulls = 0; + +SELECT 'join_use_nulls = 0'; + SELECT '-'; SELECT * FROM view_no_nulls; SELECT '-'; @@ -42,6 +55,29 @@ SELECT * FROM view_nulls_set; SELECT '-'; SELECT * FROM view_nulls; +DETACH TABLE view_no_nulls; +DETACH TABLE view_no_nulls_set; +DETACH TABLE view_nulls_set; +DETACH TABLE view_nulls; + +ATTACH TABLE view_no_nulls; +ATTACH TABLE view_no_nulls_set; +ATTACH TABLE view_nulls_set; +ATTACH TABLE view_nulls; + +SET join_use_nulls = 1; + +SELECT 'join_use_nulls = 1'; + +SELECT '-'; +SELECT * FROM view_no_nulls; -- { serverError 349 } +SELECT '-'; +SELECT * FROM view_no_nulls_set; +SELECT '-'; +SELECT * FROM view_nulls_set; +SELECT '-'; +SELECT * FROM view_nulls; + SET join_use_nulls = 0; SELECT 'join_use_nulls = 0';