Skip to content

Issue parsing postgres timestamptz as expression #1619

Closed
@tpoll

Description

@tpoll

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions