trinodb / trino

Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
https://trino.io
Apache License 2.0
10.49k stars 3.02k forks source link

SQL expression allows multiple `+` and `-` operands between values #13786

Open findinpath opened 2 years ago

findinpath commented 2 years ago
trino> create table iceberg.default.test1 (x integer, y integer);
CREATE TABLE
trino> insert into iceberg.default.test1 values (1,10), (2,20), (3,30);
INSERT: 3 rows

trino> update iceberg.default.test1 set y = y + + + + + + - + - + -6  where x = 3;
UPDATE: 1 row

Relevant part of the grammar

https://github.com/trinodb/trino/blob/master/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4#L470-L477

findepi commented 2 years ago

@findinpath This is about expressions in general

trino> SELECT y + + + + + + - + - + -6 FROM (VALUES 1) t(y);
 _col0
-------
    -5

cc @martint for triaging