diff --git a/src/Parsers/Lexer.cpp b/src/Parsers/Lexer.cpp index 8a28e2447a8..ac41dd555c8 100644 --- a/src/Parsers/Lexer.cpp +++ b/src/Parsers/Lexer.cpp @@ -146,13 +146,20 @@ Token Lexer::nextTokenImpl() } } - /// word character cannot go just after number (SELECT 123FROM) + /// Try to parse it to a identifier(1identifier_name), return ErrorWrongNumber if not if (pos < end && isWordCharASCII(*pos)) { ++pos; while (pos < end && isWordCharASCII(*pos)) ++pos; - return Token(TokenType::ErrorWrongNumber, token_begin, pos); + + for (const char * iterator = token_begin; iterator < pos; ++iterator) + { + if (!isWordCharASCII(*iterator) && *iterator != '$') + return Token(TokenType::ErrorWrongNumber, token_begin, pos); + } + + return Token(TokenType::BareWord, token_begin, pos); } return Token(TokenType::Number, token_begin, pos); diff --git a/tests/queries/0_stateless/01450_allow_dollar_sign_in_identifier.reference b/tests/queries/0_stateless/01460_allow_dollar_and_number_in_identifier.reference similarity index 50% rename from tests/queries/0_stateless/01450_allow_dollar_sign_in_identifier.reference rename to tests/queries/0_stateless/01460_allow_dollar_and_number_in_identifier.reference index 6abc4c402b8..f5b4a27081d 100644 --- a/tests/queries/0_stateless/01450_allow_dollar_sign_in_identifier.reference +++ b/tests/queries/0_stateless/01460_allow_dollar_and_number_in_identifier.reference @@ -1,2 +1,4 @@ $alias$name$ 1 +1alias1name1 +1 diff --git a/tests/queries/0_stateless/01450_allow_dollar_sign_in_identifier.sql b/tests/queries/0_stateless/01460_allow_dollar_and_number_in_identifier.sql similarity index 50% rename from tests/queries/0_stateless/01450_allow_dollar_sign_in_identifier.sql rename to tests/queries/0_stateless/01460_allow_dollar_and_number_in_identifier.sql index ba18bc5d884..5a3aa996899 100644 --- a/tests/queries/0_stateless/01450_allow_dollar_sign_in_identifier.sql +++ b/tests/queries/0_stateless/01460_allow_dollar_and_number_in_identifier.sql @@ -1 +1,2 @@ SELECT 1 AS $alias$name$ FORMAT TSVWithNames; +SELECT 1 AS 1alias1name1 FORMAT TSVWithNames;