Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Produce design for writing custom SQL parsers by extending this library #7

Open
andygrove opened this issue Sep 3, 2018 · 3 comments

Comments

@andygrove
Copy link
Member

No description provided.

@alex-dukhno
Copy link
Contributor

Hi guys, I am building a PostgreSQL compatible NewSQL database and using sqlparse-rs. I haven't encountered problems with supporting different dialects until I started working on mathematical operations that PostgreSQL supports.
I don't know how big problem to add ! factorial, !! prefix factorial, |/ square root and ||/ cube root to the parser, however, it is a problem for bitwise xor which is ^ in SQL standard and # in PostgreSQL (^ is an exponent in PostgreSQL). So I think this issue becomes somewhat critical for my project.
Currently, I see 3 possible ways for me:

  1. wait until the issue will be solved by someone else,
  2. fork the crate and work on only PostgreSQL dialect,
  3. contribute back to sqlparse-rs crate.

I am leaning to 3) option because 1) I assume will take a long time, 2) it will be a big burden for me in testing and backporting useful feature from sqlparse-rs.

The biggest obstacle for me to start contributing on the topic of the issue is that I haven't seen the "roadmap" or "design discussion" on how to make sqlparse-rs customisable for dialects. So I'd like to see if maintainers, contributors, and community have ideas or something that we could try out and start moving on the issue.

@bigkraig
Copy link

Same boat as @alex-dukhno, except that I want to extend this to support SqlAnywhere

@nickolay
Copy link
Contributor

We currently accept dialect-specific extensions in the mainline parser, trying to document the differences between the dialects as we add support for more syntax.

We don't have many examples where we weren't able to do so (#223 comes to mind, but that dialect's grammar is undocumented). I do expect that we'll have to add dialect-specific parsing at some point, probably using the approaches I wrote about in #207. Not sure if adding the operators you mention is blocked by that, probably not?

I also believe that a strictly typed Syntax tree, which we currently have, is the main limiting factor to exploring various designs to better support dialects. That's why I opened #189 in order to unblock others who may be willing to help with that.

flaneur2020 pushed a commit to flaneur2020/sqlparser-rs that referenced this issue Feb 18, 2022
Process escape character in quoted string
Taylor-lagrange added a commit to Taylor-lagrange/sqlparser-rs that referenced this issue Nov 1, 2023
* feat: support range expr parse

* chore: fix ci
serprex pushed a commit to serprex/sqlparser-rs that referenced this issue Nov 6, 2023
jmhain pushed a commit to jmhain/sqlparser-rs that referenced this issue Mar 15, 2024
* cargo fmt

* add json index for snowflake, bq

* add flatten

* add snowflake dateparts

* useful parsing errors

* parse decimals without 0 prefix

* snowflake: within group

* snowflake: json bracket syntax

* snowflake: join where

* snowflake: ilike

* snowflake: handle like ... escape ...

* snowflake: try_cast

* snowflake: qualify

* snowflake: handle pivot

* snowflake: allow idents to start with $

* snowflake: fix parsing for position

* snowflake: minus set operator

* snowflake json: cleanup/fix bracket and dot notation

* snowflake: number

* snowflake: string literal parse esc quotes

* snowflake: nested exprs can be lists

* join constraints are not required

* smarter number literal parsing with state machine for scientific notation

* snowflake: date/time field variants

* rs/pg: AT TIME ZONE

* rs: ignore/respect nulls

* tokenizer: treat zwsp as whitespace

* pg/rs: SIMILAR TO

* rs: allow brackets around idents

* rs: allow str literal date/time parts

* rs: more IS [NOT] *

* pg: add json ops

* add BigQueryDialect

* bq: backtick quoted idents

* bq: be resilient to trailing commas

* bq: be much more flexible with parsing function args

* bq: handle idents using backticks

* bq: handle interval parsing

* bq: parse regex literals (consider merging with snowflake str parsing)

* bq: add in more date/time parts

* bq: allow aliases with backtick quoting

* bq: parse wildcard modifiers except/replace

* bq: named window specs

* bq: IN <expr>

* snowflake: remove special position handling? maybe should remove more

* bq: double quoted string

* bq: typeless structs

* bq: add secret datetime fields

* fixup bq args bs

* snowflake: ignore/respect nulls for window funcs

* Added Unpivot. Fixed some Pivot (apache#2)

-- Technically, unpivot has some stricter
   expr requirements (eg instead of expr for ident in col_list
   it should be <column> for ident in col_list). I haven't been
   able to navigate to find this stricter definition yet, but
   maybe we want this fix ASAP.

* [SIG-13647] allow idents for limits and offsets (apache#3)

* Fix compilation issues (apache#5)

* Use enum to prevent &'static str lifetime issues

-- Could also use `serde(bound(deserialize = "'de: 'static"))`
-- But I think that will need to be applied on all structs
-- that depend on Expr... which I assume will be ubiquitous

* Make WindowSpec serializable

* Fix more static str stuff

* Fixed tests

* Fixed all compilation errors

* Run clippy --fix

* Fixd lint errors

* Fix more lint errors

* Fix remaining lint issues

* Fix tests pass (apache#7)

* Fixed trivial tests failures

* Fixed more tests

* Ignored backcompat breaks... for now

* More simple tests fixes

* Fixed tests... but not sure whether this is right

* Clippy

* cargo fmt

* Fixed regression apache#1

* Fixed second regression

* Ignore snowflake numeric failing test

* Added tests for sigma-related parser changes (apache#8)

* Added regression tests

* Added test for sigma-related parser changes

* Amended comments

* Removed extraneous println

* Fixed build errors part 1

* Manual cargo fmt because it's hanging on my machine

* When you fail at %s

Co-authored-by: Mark Wong Siang Kai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants