Skip to content

Commit 47bf728

Browse files
removing no longer needed logic around rhs arg parens for IN
1 parent 882c783 commit 47bf728

2 files changed

Lines changed: 1 addition & 29 deletions

File tree

src/Parsers/ASTFunction.cpp

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -446,33 +446,7 @@ void ASTFunction::formatImplWithoutAlias(WriteBuffer & ostr, const FormatSetting
446446
arguments->children[0]->format(ostr, settings, state, nested_need_parens);
447447
ostr << it->operator_name;
448448

449-
/// Format x IN 1 as x IN (1): put parens around rhs even if there is a single element in set.
450-
const auto * second_arg_func = arguments->children[1]->as<ASTFunction>();
451-
const auto * second_arg_literal = arguments->children[1]->as<ASTLiteral>();
452-
bool is_literal_tuple_or_array = second_arg_literal
453-
&& (second_arg_literal->value.getType() == Field::Types::Tuple
454-
|| second_arg_literal->value.getType() == Field::Types::Array);
455-
456-
/** Conditions for extra parens:
457-
* 1. Is IN operator
458-
* 2. 2nd arg is not subquery, function, or literal tuple or array
459-
* 3. If the 2nd argument has alias, we ignore condition 2 and add extra parens
460-
*
461-
* Condition 3 is needed to avoid inconsistency in format-parse-format debug check in executeQuery.cpp
462-
*/
463-
bool extra_parents_around_in_rhs = is_in_operator
464-
&& ((!arguments->children[1]->as<ASTSubquery>() && !second_arg_func && !is_literal_tuple_or_array)
465-
|| !arguments->children[1]->tryGetAlias().empty());
466-
467-
if (extra_parents_around_in_rhs)
468-
{
469-
ostr << '(';
470-
arguments->children[1]->format(ostr, settings, state, nested_dont_need_parens);
471-
ostr << ')';
472-
}
473-
474-
if (!extra_parents_around_in_rhs)
475-
arguments->children[1]->format(ostr, settings, state, nested_need_parens);
449+
arguments->children[1]->format(ostr, settings, state, nested_need_parens);
476450

477451
if (need_parens_around_in)
478452
ostr << ')';

tests/queries/0_stateless/03359_analyzer_rewrite_view_query.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
set enable_analyzer=1;
2-
31
CREATE TABLE mydestination
42
(
53
`object` String

0 commit comments

Comments
 (0)