Skip to content

The query formatting is broken: SELECT NOT 0 + NOT 0 #60029

@Algunenano

Description

@Algunenano

Fuzzer: https://s3.amazonaws.com/clickhouse-test-reports/60028/2d42054845c123895b77b2be3166f7f3638c4992/ast_fuzzer__asan_.html

Found error: The query formatting is broken.
Changed settings: receive_timeout = '10', receive_data_timeout_ms = '10000', allow_suspicious_low_cardinality_types = '1', group_by_two_level_threshold = '100000', enable_positional_arguments = '1', log_queries = '0', max_rows_to_read = '1', log_comment = '/workspace/ch/tests/queries/0_stateless/02920_unary_operators_functions.sql', send_logs_level = 'fatal', check_query_single_value_result = '1', mutations_sync = '2', optimize_use_implicit_projections = '1', allow_deprecated_syntax_for_merge_tree = '1'
No changed MergeTree settings.
Got the following (different) text after formatting the fuzzed query and parsing it back:
'SELECT NOT (0 + NOT 0)'
, expected:
'SELECT NOT 0 + NOT 0'
In more detail:
AST-1 (generated by fuzzer):
'SelectWithUnionQuery, 0x0000513002979998
-ExpressionList, 0x0000511001cbdd58
--SelectQuery, 0x0000511002bb80d8
---ExpressionList, 0x0000511001a98758
----Function_plus, 0x0000513002d945d8
-----ExpressionList, 0x0000511001a4e018
------Function_not, 0x000051300328fc98
-------ExpressionList, 0x0000511002102698
--------ExpressionList, 0x0000511001a82bd8
---------Literal_UInt64_0, 0x000051300298b518
------Function_not, 0x00005130024aff18
-------ExpressionList, 0x00005110003ce158
--------ExpressionList, 0x0000511000b5a318
---------Literal_UInt64_0, 0x0000513002c2c858
'
Text-1 (AST-1 formatted):
'SELECT (NOT 0) + (NOT 0)'
AST-2 (Text-1 parsed):
'SelectWithUnionQuery, 0x00005130022d5b18
-ExpressionList, 0x0000511000652618
--SelectQuery, 0x0000511000416458
---ExpressionList, 0x0000511002d64418
----Function_plus, 0x00005130015c3098
-----ExpressionList, 0x0000511002d58398
------Function_not, 0x00005130022d5e98
-------ExpressionList, 0x0000511000b6ac18
--------Literal_UInt64_0, 0x00005130028f8898
------Function_not, 0x0000513003196d98
-------ExpressionList, 0x0000511002b29518
--------Literal_UInt64_0, 0x0000513000467c98
'
Text-2 (AST-2 formatted):
'SELECT NOT 0 + NOT 0'
AST-3 (Text-2 parsed):
'SelectWithUnionQuery, 0x00005130017e4ed8
-ExpressionList, 0x0000511003528398
--SelectQuery, 0x00005110031413d8
---ExpressionList, 0x0000511001cf4498
----Function_not, 0x000051300294fed8
-----ExpressionList, 0x0000511002b59fd8
------Function_plus, 0x000051300061aa98
-------ExpressionList, 0x000051100014f2d8
--------Literal_UInt64_0, 0x000051300313f758
--------Function_not, 0x0000513001476898
---------ExpressionList, 0x0000511000fe5a18
----------Literal_UInt64_0, 0x0000513002b7d158
'
Text-3 (AST-3 formatted):
'SELECT NOT (0 + NOT 0)'
Text-3 must be equal to Text-2, but it is not.
SELECT formatQuery('SELECT NOT 0 + NOT 0')

Query id: a16f5625-8b60-4708-ade1-6bbbb0f2755a

┌─formatQuery('SELECT NOT 0 + NOT 0')─┐
│ SELECT NOT (0 + NOT 0)              │
└─────────────────────────────────────┘

1 row in set. Elapsed: 0.000 sec. 

^ These 2 queries are different

Metadata

Metadata

Assignees

Labels

fuzzProblem found by one of the fuzzers

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions