Skip to content

Inconsistent parsing of tuples #62975

@tavplubix

Description

@tavplubix
4982:2024.04.24 23:02:20.357164 [ 169 ] {a063f8da-4356-4072-8e76-5192b0e292b4} <Fatal> : Logical error: 'Inconsistent AST formatting: the query:
54983-SELECT ((('a', 1, 10) AS x).1) = 'a' FROM remote('127.0.0.{1,2,3}', numbers(2))
54984-Was parsed and formatted back as:
54985-SELECT (tuple(('a', 1, 10) AS x).1) = 'a' FROM remote('127.0.0.{1,2,3}', numbers(2))'.

The problem is that it parses a tuple in parenthesis as a nested tuple of one-element tuple. This is not consistent with other literals:

localhost.localdomain :) SELECT toTypeName((('a', 1, 10) AS x))

SELECT toTypeName(tuple(('a', 1, 10) AS x))

Query id: f7e739da-50a6-4a00-a7d1-b2dbb569e96c

   ┌─toTypeName(tuple(('a', 1, 10)))────┐
1. │ Tuple(Tuple(String, UInt8, UInt8)) │
   └────────────────────────────────────┘

1 row in set. Elapsed: 0.016 sec. 

localhost.localdomain :) SELECT toTypeName(((1 as x)))

SELECT toTypeName(1 AS x)

Query id: b96ccfc1-e28d-41b0-94ad-7d2e86388454

   ┌─toTypeName(1)─┐
1. │ UInt8         │
   └───────────────┘

1 row in set. Elapsed: 0.013 sec. 

Metadata

Metadata

Assignees

Labels

fuzzProblem found by one of the fuzzers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions