From 5004e4d2cc48c652393df60fa67b93e32df0c21e Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sun, 18 Aug 2024 03:27:05 +0200 Subject: [PATCH 1/5] Miscellaneous --- src/Analyzer/Resolve/QueryAnalyzer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Analyzer/Resolve/QueryAnalyzer.cpp b/src/Analyzer/Resolve/QueryAnalyzer.cpp index 004da5ed341..fa977e40226 100644 --- a/src/Analyzer/Resolve/QueryAnalyzer.cpp +++ b/src/Analyzer/Resolve/QueryAnalyzer.cpp @@ -3679,10 +3679,10 @@ ProjectionNames QueryAnalyzer::resolveExpressionNode( auto hints = IdentifierResolver::collectIdentifierTypoHints(unresolved_identifier, valid_identifiers); - throw Exception(ErrorCodes::UNKNOWN_IDENTIFIER, "Unknown {}{} identifier '{}' in scope {}{}", + throw Exception(ErrorCodes::UNKNOWN_IDENTIFIER, "Unknown {}{} identifier {} in scope {}{}", toStringLowercase(IdentifierLookupContext::EXPRESSION), message_clarification, - unresolved_identifier.getFullName(), + backQuote(unresolved_identifier.getFullName()), scope.scope_node->formatASTForErrorMessage(), getHintsErrorMessageSuffix(hints)); } From 95edca513c3f1cc8677b637facdaaf916f3a71c2 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sun, 18 Aug 2024 05:43:01 +0200 Subject: [PATCH 2/5] Fix tests --- .../0_stateless/03096_text_log_format_string_args_not_empty.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/queries/0_stateless/03096_text_log_format_string_args_not_empty.sql b/tests/queries/0_stateless/03096_text_log_format_string_args_not_empty.sql index 0e60ee77fe5..12fd26e2141 100644 --- a/tests/queries/0_stateless/03096_text_log_format_string_args_not_empty.sql +++ b/tests/queries/0_stateless/03096_text_log_format_string_args_not_empty.sql @@ -8,6 +8,6 @@ system flush logs; select count() > 0 from system.text_log where message_format_string = 'Peak memory usage{}: {}.' and value1 is not null and value2 like '% MiB'; -select count() > 0 from system.text_log where level = 'Error' and message_format_string = 'Unknown {}{} identifier \'{}\' in scope {}{}' and value1 = 'expression' and value3 = 'count' and value4 = 'SELECT count'; +select count() > 0 from system.text_log where level = 'Error' and message_format_string = 'Unknown {}{} identifier `{}` in scope {}{}' and value1 = 'expression' and value3 = 'count' and value4 = 'SELECT count'; select count() > 0 from system.text_log where level = 'Error' and message_format_string = 'Function with name \'{}\' does not exist. In scope {}{}' and value1 = 'conut' and value2 = 'SELECT conut()' and value3 ilike '%\'count\'%'; From 4bb2f7b3f61ee1abb2c493dc44e5101485eb6675 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sun, 18 Aug 2024 09:09:58 +0200 Subject: [PATCH 3/5] Miscellaneous --- src/Analyzer/Resolve/QueryAnalyzer.cpp | 12 ++++++------ tests/integration/test_access_for_functions/test.py | 2 +- .../test.py | 2 +- .../test_user_defined_object_persistence/test.py | 6 +++--- .../03096_text_log_format_string_args_not_empty.sql | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Analyzer/Resolve/QueryAnalyzer.cpp b/src/Analyzer/Resolve/QueryAnalyzer.cpp index fa977e40226..427b583861b 100644 --- a/src/Analyzer/Resolve/QueryAnalyzer.cpp +++ b/src/Analyzer/Resolve/QueryAnalyzer.cpp @@ -2564,8 +2564,8 @@ void checkFunctionNodeHasEmptyNullsAction(FunctionNode const & node) if (node.getNullsAction() != NullsAction::EMPTY) throw Exception( ErrorCodes::SYNTAX_ERROR, - "Function with name '{}' cannot use {} NULLS", - node.getFunctionName(), + "Function with name {} cannot use {} NULLS", + backQuote(node.getFunctionName()), node.getNullsAction() == NullsAction::IGNORE_NULLS ? "IGNORE" : "RESPECT"); } } @@ -3228,16 +3228,16 @@ ProjectionNames QueryAnalyzer::resolveFunction(QueryTreeNodePtr & node, Identifi auto hints = NamePrompter<2>::getHints(function_name, possible_function_names); throw Exception(ErrorCodes::UNKNOWN_FUNCTION, - "Function with name '{}' does not exist. In scope {}{}", - function_name, + "Function with name {} does not exist. In scope {}{}", + backQuote(function_name), scope.scope_node->formatASTForErrorMessage(), getHintsErrorMessageSuffix(hints)); } if (!function_lambda_arguments_indexes.empty()) throw Exception(ErrorCodes::UNSUPPORTED_METHOD, - "Aggregate function '{}' does not support lambda arguments", - function_name); + "Aggregate function {} does not support lambda arguments", + backQuote(function_name)); auto action = function_node_ptr->getNullsAction(); std::string aggregate_function_name = rewriteAggregateFunctionNameIfNeeded(function_name, action, scope.context); diff --git a/tests/integration/test_access_for_functions/test.py b/tests/integration/test_access_for_functions/test.py index 82125b35b49..138152904a8 100644 --- a/tests/integration/test_access_for_functions/test.py +++ b/tests/integration/test_access_for_functions/test.py @@ -42,7 +42,7 @@ def test_access_rights_for_function(): function_resolution_error = instance.query_and_get_error("SELECT MySum(1, 2)") assert ( "Unknown function MySum" in function_resolution_error - or "Function with name 'MySum' does not exist." in function_resolution_error + or "Function with name `MySum` does not exist." in function_resolution_error ) instance.query("REVOKE CREATE FUNCTION ON *.* FROM A") diff --git a/tests/integration/test_sql_user_defined_functions_on_cluster/test.py b/tests/integration/test_sql_user_defined_functions_on_cluster/test.py index dc36a7b32b8..76dc254c84e 100644 --- a/tests/integration/test_sql_user_defined_functions_on_cluster/test.py +++ b/tests/integration/test_sql_user_defined_functions_on_cluster/test.py @@ -28,7 +28,7 @@ def test_sql_user_defined_functions_on_cluster(): error_message = node.query_and_get_error("SELECT test_function(1);") assert ( "Unknown function test_function" in error_message - or "Function with name 'test_function' does not exist. In scope SELECT test_function(1)" + or "Function with name `test_function` does not exist. In scope SELECT test_function(1)" in error_message ) diff --git a/tests/integration/test_user_defined_object_persistence/test.py b/tests/integration/test_user_defined_object_persistence/test.py index bd491dfa195..eb6b3621a54 100644 --- a/tests/integration/test_user_defined_object_persistence/test.py +++ b/tests/integration/test_user_defined_object_persistence/test.py @@ -43,20 +43,20 @@ def test_persistence(): error_message = instance.query_and_get_error("SELECT MySum1(1, 2)") assert ( "Unknown function MySum1" in error_message - or "Function with name 'MySum1' does not exist. In scope SELECT MySum1(1, 2)" + or "Function with name `MySum1` does not exist. In scope SELECT MySum1(1, 2)" in error_message ) error_message = instance.query_and_get_error("SELECT MySum2(1, 2)") assert ( "Unknown function MySum2" in error_message - or "Function with name 'MySum2' does not exist. In scope SELECT MySum2(1, 2)" + or "Function with name `MySum2` does not exist. In scope SELECT MySum2(1, 2)" in error_message ) error_message = instance.query_and_get_error("SELECT MyUnion()") assert ( "Unknown function MyUnion" in error_message - or "Function with name 'MyUnion' does not exist. In scope SELECT MyUnion" + or "Function with name `MyUnion` does not exist. In scope SELECT MyUnion" in error_message ) diff --git a/tests/queries/0_stateless/03096_text_log_format_string_args_not_empty.sql b/tests/queries/0_stateless/03096_text_log_format_string_args_not_empty.sql index 12fd26e2141..6cd71ac3270 100644 --- a/tests/queries/0_stateless/03096_text_log_format_string_args_not_empty.sql +++ b/tests/queries/0_stateless/03096_text_log_format_string_args_not_empty.sql @@ -8,6 +8,6 @@ system flush logs; select count() > 0 from system.text_log where message_format_string = 'Peak memory usage{}: {}.' and value1 is not null and value2 like '% MiB'; -select count() > 0 from system.text_log where level = 'Error' and message_format_string = 'Unknown {}{} identifier `{}` in scope {}{}' and value1 = 'expression' and value3 = 'count' and value4 = 'SELECT count'; +select count() > 0 from system.text_log where level = 'Error' and message_format_string = 'Unknown {}{} identifier {} in scope {}{}' and value1 = 'expression' and value3 = 'count' and value4 = 'SELECT count'; -select count() > 0 from system.text_log where level = 'Error' and message_format_string = 'Function with name \'{}\' does not exist. In scope {}{}' and value1 = 'conut' and value2 = 'SELECT conut()' and value3 ilike '%\'count\'%'; +select count() > 0 from system.text_log where level = 'Error' and message_format_string = 'Function with name {} does not exist. In scope {}{}' and value1 = 'conut' and value2 = 'SELECT conut()' and value3 ilike '%\'count\'%'; From f88b5988c1439dc40a164bf98d3b3f0d5bcd4f44 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sun, 18 Aug 2024 09:44:39 +0200 Subject: [PATCH 4/5] Update test --- .../03096_text_log_format_string_args_not_empty.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/queries/0_stateless/03096_text_log_format_string_args_not_empty.sql b/tests/queries/0_stateless/03096_text_log_format_string_args_not_empty.sql index 6cd71ac3270..bb036a6c133 100644 --- a/tests/queries/0_stateless/03096_text_log_format_string_args_not_empty.sql +++ b/tests/queries/0_stateless/03096_text_log_format_string_args_not_empty.sql @@ -8,6 +8,6 @@ system flush logs; select count() > 0 from system.text_log where message_format_string = 'Peak memory usage{}: {}.' and value1 is not null and value2 like '% MiB'; -select count() > 0 from system.text_log where level = 'Error' and message_format_string = 'Unknown {}{} identifier {} in scope {}{}' and value1 = 'expression' and value3 = 'count' and value4 = 'SELECT count'; +select count() > 0 from system.text_log where level = 'Error' and message_format_string = 'Unknown {}{} identifier {} in scope {}{}' and value1 = 'expression' and value3 = '`count`' and value4 = 'SELECT count'; -select count() > 0 from system.text_log where level = 'Error' and message_format_string = 'Function with name {} does not exist. In scope {}{}' and value1 = 'conut' and value2 = 'SELECT conut()' and value3 ilike '%\'count\'%'; +select count() > 0 from system.text_log where level = 'Error' and message_format_string = 'Function with name {} does not exist. In scope {}{}' and value1 = '`conut`' and value2 = 'SELECT conut()' and value3 ilike '%\'count\'%'; From f97551e2ad8622cf87c1b4f9f6231f256a48742a Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sun, 18 Aug 2024 22:17:16 +0200 Subject: [PATCH 5/5] Fix tests --- tests/integration/test_storage_azure_blob_storage/test.py | 2 +- tests/integration/test_storage_hdfs/test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_storage_azure_blob_storage/test.py b/tests/integration/test_storage_azure_blob_storage/test.py index fbdc7f29f98..8e18a6a8d02 100644 --- a/tests/integration/test_storage_azure_blob_storage/test.py +++ b/tests/integration/test_storage_azure_blob_storage/test.py @@ -1608,7 +1608,7 @@ def test_hive_partitioning_without_setting(cluster): f"blob_path='{path}', format='CSV', structure='{table_format}') WHERE column1=_column1;" ) pattern = re.compile( - r"DB::Exception: Unknown expression identifier '.*' in scope.*", re.DOTALL + r"DB::Exception: Unknown expression identifier `.*` in scope.*", re.DOTALL ) with pytest.raises(Exception, match=pattern): diff --git a/tests/integration/test_storage_hdfs/test.py b/tests/integration/test_storage_hdfs/test.py index fdbf7c5bacb..79b59191e93 100644 --- a/tests/integration/test_storage_hdfs/test.py +++ b/tests/integration/test_storage_hdfs/test.py @@ -1296,7 +1296,7 @@ def test_hive_partitioning_without_setting(started_cluster): == f"Elizabeth\tGordon\n" ) pattern = re.compile( - r"DB::Exception: Unknown expression identifier '.*' in scope.*", re.DOTALL + r"DB::Exception: Unknown expression identifier `.*` in scope.*", re.DOTALL ) with pytest.raises(QueryRuntimeException, match=pattern):