Closed
Description
Postgres has syntax that allows you to write a query such as:
SELECT * from table where x >= timestamptz '2021-07-05 00:00:00+00'
This fails to parse with an exception
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "\'2021-07-05 00:00:00+00\'" <S_CHAR_LITERAL>
at line 1, column 44.
Interestingly SELECT * from table where x >= timestamptz('2021-07-05 00:00:00+00') (note the parens) does parse.
I also tested SELECT * from table where x >= timestamp '2021-07-05 00:00:00+00' which does properly parse.
I'm not too familiar with the parsing grammar, but it seems like maybe timestamptz just needs to be treated similarly to timestamp?
Happy to open up a PR if someone can point me in the right direction to get started.
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Issue parsing postgres timestamptz [/-][+]Issue parsing postgres timestamptz as expression[/+]manticore-projects commentedon Aug 19, 2022
Greetings @tpoll. Thank you for considering to solve it by yourself.
You would need to:
4( Submit your PR
(Usually there is more to do, but in this case just adding a token could do.)
manticore-projects commentedon Aug 19, 2022
Simply because
Anything(...)is parsed as aFunction()(without understanding the particular means or purpose ofAnything).But since
timestamptz '2021-07-05 00:00:00+00'does not match aFunction()and not any allowedDATE_TIME_LITERALyou will need to declare it in the Grammar.tpoll commentedon Aug 19, 2022
Thanks for the pointers @manticore-projects. I opened up a PR which I believe should safely add support.