Parser fails when query contains redundant brackets
sqlparser fails with error "Expected ), found: t2" when the query contains redundant brackets, although the query is valid. Example (mysql query):
insert into t1 (id, name)
(select t2.id, t2.name
from t2
left join t1 target
on target.id <=> t2.id
where target.id is null)
on duplicate key update t1.id = t1.id
In the above example, the parser will return a successful result only after removing the brackets around the select.
Thank you for the report @nataliezeller1
Do you know of another system that supports this type of syntax?
@alamb Redshift also supports this syntax, for example -
insert into t1 (id, name)
(select t2.id, t2.name
from t2
left join t1 target
on target.id = t2.id
where target.id is null);
Not sure about other DBs
@alamb Snowflake also supports this syntax.
Sounds like it would be a good improvement to add to the parser