GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Issue parsing postgres timestamptz as expression · Issue #1619 · JSQLParser/JSqlParser

Issue parsing postgres timestamptz as expression #1619

New issue
Copy link
New issue
Copy link
Closed
#1621
Closed
Issue parsing postgres timestamptz as expression#1619
#1621
Copy link

Description

@tpoll
tpoll
opened on Aug 18, 2022
Issue body actions

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.

Activity

  1. tpoll
    changed the title [-]Issue parsing postgres timestamptz [/-] [+]Issue parsing postgres timestamptz as expression[/+] on Aug 18, 2022
  2. manticore-projects commented on Aug 19, 2022

    @manticore-projects
    manticore-projects
    on Aug 19, 2022
    Contributor
    More actions

    Greetings @tpoll. Thank you for considering to solve it by yourself.

    You would need to:

    1. Edit the JavaCC Grammar and add your new Token
    2. Add a Test Case to Parse and Deparse your statement
    3. Run all Tests to ensure, that everything is still working
      4( Submit your PR

    (Usually there is more to do, but in this case just adding a token could do.)

  3. manticore-projects commented on Aug 19, 2022

    @manticore-projects
    manticore-projects
    on Aug 19, 2022
    Contributor
    More actions

    Interestingly SELECT * from table where x >= timestamptz('2021-07-05 00:00:00+00') (note the parens) does parse.

    Simply because Anything(...) is parsed as a Function() (without understanding the particular means or purpose of Anything).
    But since timestamptz '2021-07-05 00:00:00+00' does not match a Function() and not any allowed DATE_TIME_LITERAL you will need to declare it in the Grammar.

  4. tpoll commented on Aug 19, 2022

    @tpoll
    tpoll
    on Aug 19, 2022
    ContributorAuthor
    More actions

    Thanks for the pointers @manticore-projects. I opened up a PR which I believe should safely add support.

  5. wumpz
    closed this as completedin #1621on Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.