Commit graph

294 commits

Author SHA1 Message Date
Mustafa Akur
1b86abebe2
Add support for first, last aggregate function parsing (#882)
* Add order by parsing to functions

* Fix doc error

* minor changes
2023-05-18 14:59:14 -04:00
Maciej Obuchowski
3be19c7666
truncate: table as optional keyword (#883)
Signed-off-by: Maciej Obuchowski <obuchowski.maciej@gmail.com>
2023-05-18 14:55:02 -04:00
Andrew Lamb
be85f54ca3
Fix logical merge conflict (#865) 2023-05-02 07:07:56 -04:00
Armin Primadi
0ff863b2c7
Add support for query source in COPY .. TO statement (#858)
* Add support for query source in COPY .. TO statement

* Fix compile error
2023-05-01 15:39:18 -04:00
Aljaž Mur Eržen
0113bbd924
Test trailing commas (#859)
* test: add tests for trailing commas

* tweaks
2023-05-01 08:31:17 -04:00
Aljaž Mur Eržen
3b1076c194
Support DISTINCT ON (...) (#852)
* Support "DISTINCT ON (...)"

* a test

* fix the merge
2023-04-27 15:34:54 -04:00
Andrew Lamb
00d071286b
Move tests from parser.rs to appropriate parse_XX tests (#845)
* Move tests from parser.rs to appropriate parse_XX tests

* move to postgres tests

* move more tests
2023-04-10 09:48:23 -04:00
sam
a8a8e65b7c
PostgreSQL: GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY and GENERATED ALWAYS AS ( generation_expr ) support (#832)
* GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ ( sequence_options ) basic impl - test are failing.

* PostgreSQL GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ ( sequence_options ) and GENERATED ALWAYS AS ( generation_expr ) STORED implementation.
2023-03-16 05:54:00 -04:00
pawel.leszczynski
4ff3aeb040
support IF EXISTS in COMMENT statements (#831)
* support IF EXISTS in COMMENT statements

Signed-off-by: Pawel Leszczynski <leszczynski.pawel@gmail.com>

* Update src/ast/mod.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

---------

Signed-off-by: Pawel Leszczynski <leszczynski.pawel@gmail.com>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2023-03-09 08:06:39 -05:00
Andrew Lamb
7f4c9132d7
Fix table alias parsing regression in 0.31.0 by backing out redshift column definition list (#827)
* Fix table alias parsing regression

* Revert "Support redshift's columns definition list for system information functions (#769)"

This reverts commit c35dcc93a7.
2023-03-06 11:43:22 -05:00
Mykhailo Bondarenko
1cf913e717
feat: Support PostgreSQL exponentiation. (#813)
* Add Postgres exponent operator

* Parse caret as BinaryOperator::PGExp in PostgreSQL

* Update sqlparser_postgres.rs

* update tests to support PGExp

* cargo fmt

* improve extensibility

* cargo fmt

* redundant code and documentation lionks
2023-03-02 10:39:39 -05:00
Maciej Skrzypkowski
c35dcc93a7
Support redshift's columns definition list for system information functions (#769)
* parsing of redshift's column definition list for
pg_get_late_binding_view_cols
pg_get_cols
pg_get_grantee_by_iam_role
pg_get_iam_role_by_user

* Renamed ColsDefinition to TableAliasDefinition

added generic dialect

* Tests fixed

* Visitor for IdentPair

* Parsing redshift table alias based on indentifier and
parentheses instead of function name

* fix clippy

---------

Co-authored-by: Maciej Skrzypkowski <maciej.skrzypkowski@satoricyber.com>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2023-02-17 14:04:59 -05:00
Y Togami
b31ede7733
chore: fix clippy error in ci (#803)
* chore: fix clippy error in ci

* chore: fix fmt
2023-02-17 13:24:50 -05:00
Alex Vasilev
072ccc0d76
feat: dollar-quoted strings support (#772)
* feat: support dollar-quoted strings

* remove comment

* unused code

* removed debugging

* added tests

* fmt

* clippy

* updated tests
2022-12-29 07:52:17 -05:00
zidaye
2d801c9fb6
Support DROP FUNCTION syntax (#752)
* drop function

* update  and  to Option

* fix review

* update

* fmt
2022-12-28 07:57:51 -05:00
Audun Skaugen
3d5cc54dcf
Generalize conflict target (#762)
Postgres supports `ON CONFLICT ON CONSTRAINT <constraint_name>` to
explicitly name the constraint that fails. Support this.
2022-12-17 07:38:57 -05:00
Audun Skaugen
6d6eb4bc9b
Support json operators @> <@ #- @? and @@
postgres supports a bunch more json operators. See
https://www.postgresql.org/docs/15/functions-json.html

Skipping operators starting with a question mark for now, since those
are hard to distinguish from placeholders without more context.
2022-12-14 14:54:56 -05:00
Audun Skaugen
fb02344131
Generalize locking clause (#759)
Postgres supports more generalized locking clauses, for example:
FOR UPDATE OF <table_name> SKIP LOCKED

also, multiple locking clauses. Generalize the parser to support these.

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2022-12-13 17:19:07 -05:00
zidaye
6c545195e1
support create function definition with $$ (#755)
* support create function definition using '2700775'

* fix warn
2022-12-13 17:15:33 -05:00
Augusto Fotino
b3688513eb
feat: add support for except clause on wildcards (#745) 2022-12-05 14:03:59 -05:00
Runji Wang
5b53df97c4
Support postgres CREATE FUNCTION (#722)
* support basic pg CREATE FUNCTION

Signed-off-by: Runji Wang <wangrunji0408@163.com>

* support function argument

Signed-off-by: Runji Wang <wangrunji0408@163.com>

* fix display and use verify in test

Signed-off-by: Runji Wang <wangrunji0408@163.com>

* support OR REPLACE

Signed-off-by: Runji Wang <wangrunji0408@163.com>

* fix compile error in bigdecimal

Signed-off-by: Runji Wang <wangrunji0408@163.com>

* unify all `CreateFunctionBody` to a structure

Signed-off-by: Runji Wang <wangrunji0408@163.com>

Signed-off-by: Runji Wang <wangrunji0408@163.com>
2022-12-01 16:08:49 -05:00
Aljaž Mur Eržen
8e1c90c0d8
Support MySQL ROWS syntax for VALUES (#737)
* Adapt VALUES to MySQL dialect

* Update src/ast/query.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

* remove *requirement* for ROW

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2022-12-01 09:46:55 -05:00
zidaye
042effdf14
update on conflict method (#735) 2022-11-30 13:33:33 -05:00
Augusto Fotino
fa6bd01b19
Support EXCLUDE support for snowflake and generic dialect (#721)
The exclude clause can be used after a possibly qualified on SELECT
2022-11-30 12:29:43 -05:00
Augusto Fotino
5e1d9f8d6e
Derive PartialOrd, Ord, and Copy whenever possible (#717)
This allow other projects to use our structures inside others that need
those.
2022-11-30 12:25:59 -05:00
unvalley
4b1dc1abf7
Support UPDATE ... FROM ( subquery ) in some dialects (#694)
* Apply UPDATE SET FROM statement for some dialects

* Add GenericDialect to support

* Test SnowflakeDialect

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2022-11-11 16:37:09 -05:00
main()
814367a6ab
Implement ON CONFLICT and RETURNING (#666)
* Implement RETURNING on INSERT/UPDATE/DELETE

* Implement INSERT ... ON CONFLICT

* Fix tests

* cargo fmt

* tests: on conflict and returning

Co-authored-by: gamife <gamife9886@gmail.com>
2022-11-11 16:15:31 -05:00
Augusto Fotino
65c5a37bce
feat: add precision for TIME, DATETIME, and TIMESTAMP data types (#701)
Now all those statements are both parsed and displayed with precision
and timezone info. Tests were added to the ones presented in the ANSI
standard.
2022-11-11 16:06:57 -05:00
omer-shtivi
0428ac742b
Add MySql, BigQuery to all dialects (#697)
* Add MySql, BigQuery to all dialects

* move unsupported on mysql from common
2022-11-07 15:32:47 -05:00
unvalley
f7817bc7c2
Support DISTINCT for SetOperator (#689)
* Update SetOperation field all to op_option

* Implement parse_set_operator_option

cargo fmt

Fix parse_set_operator_option after next_token

* Add test for parsing union distinct

* Rename to SetQualifier and fix fmt space

* Add None to SetQualifier

* Update parse method

* Rename to SetQuantifier

* Rename parse_set_operator_option parse_set_operator

* Fix test to parse union, except, intersect

* Add some comments to SetQuantifier

* Fix comment
2022-11-07 07:05:59 -05:00
yuval-illumex
0f7e144890
Support the ARRAY type of Snowflake (#699)
* Snowflake Array

* Use the array data type

* Try to fix build

* Try to fix build

* Change Array to option

* Remove unused import
2022-11-04 10:25:25 -04:00
sam
bbf32a9e81
Support create sequence with options INCREMENT, MINVALUE, MAXVALUE, START etc. (#681)
* Creat sequence options model

[ INCREMENT [ BY ] increment ]
    [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
    [ START [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ]
    [ OWNED BY { table_name.column_name | NONE } ]

* Fix for format! not avalable in --target thumbv6m-none-eabi

* Fix for format! not avalable in --target thumbv6m-none-eabi

* Fix for format! not avalable in --target thumbv6m-none-eabi

* Fix for format! not avalable in --target thumbv6m-none-eabi

* Updated parser for sequence options

* Updated parser for sequence options

* Update src/ast/mod.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2022-11-03 09:16:43 -04:00
sam
e3c936a6ce
mod, parser and test cases for CREATE [ { TEMPORARY | TEMP } ] SEQUENCE [ IF NOT EXISTS ] (#678) 2022-10-19 17:21:17 -04:00
sam
b32cbbd855
Support drop sequence statement (#673)
* Add ObjectType Sequence

* Drop sequence test cases added.

* Parser and Drop statement Display updated.

* Parser and Drop statement Display updated.

* Fix compile errors

* add new test case
2022-10-15 08:04:19 -04:00
AugustoFKL
cacdf3305f
Add support for unit on char length units for small character string types. (#663)
This results in complete support for ANSI CHARACTER, CHAR, CHARACTER VARYING,
CHAR VARYING, and VARCHAR.
2022-10-11 08:54:15 -04:00
AugustoFKL
777672625f
Replacing the two booleans from 'SET ROLE' to a single enum. (#664)
This way, we don't rely on the parser to have valid structures for that
statement, as the structure itself is valid.
2022-10-10 17:14:37 -04:00
AugustoFKL
f7f14df4b1
647 Adding all ansii character string types, parsing them, and differentiating between each one (#648) 2022-10-04 06:42:29 -04:00
AugustoFKL
95464ec72c
Change TIMESTAMP and TIME parsing so that time zone information is preserved (#641)
* 640 Fixing time zone printing format for TIMESTAMP and TIME

* 640 Removing unnecessary changes

* Update src/ast/data_type.rs

Fix comment typo

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2022-10-03 08:37:17 -04:00
Andrew Lamb
6afd194e94
Disambiguate CREATE ROLE ... USER and GROUP (#628) 2022-09-27 13:56:29 -04:00
Andrew Lamb
2b21da2439
Add test for optional WITH in CREATE ROLE (#627) 2022-09-27 10:23:33 -04:00
Ben Cook
91087fcba0
Support CREATE ROLE and DROP ROLE (#598)
* Parse GRANT ROLE and DROP ROLE

* Gate create role on dialect

* cargo fmt

* clippy

* no-std

* clippy again
2022-09-27 09:58:36 -04:00
Dmitry Patsura
6d8aacd85b
feat: Support expression in SET statement (#574)
Co-authored-by: Alex Vasilev <vaspiring@gmail.com>
2022-08-18 13:29:55 -04:00
Alex Qyoun-ae
31ba0012f7
Support PostgreSQL array subquery constructor (#566) 2022-08-12 14:08:56 -04:00
Dmitry Patsura
54a29e872d
feat: Parse special keywords as functions (current_user, user, etc) (#561)
* feat: Parse special keywors as functions (current_user, user, etc)

* explain special field
2022-08-11 08:30:06 -04:00
Kaushik Iska
1c64129f76
[postgres] Add support for custom binary operators (#548)
* [postgres] Add support for custom binary operators

More details about operators in general are at:
https://www.postgresql.org/docs/current/sql-createoperator.html. This
patch attempts to parse `SELECT` queries that reference an operator
using `OPERATOR(<optional_schema>.<operator_name>)` syntax.

This is a PostgreSQL extension. There are no provisions for user-defined operators in the SQL standard.

* fix code-review comments and ci failures

* Allow custom operator in generic dialects too

* Parse `OPERATOR` as Vec<String>

* fix: std

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2022-08-05 13:53:58 -04:00
Dmitry Patsura
6c98228e71
feat: Allow to use >> and << binary operators in Generic dialect (#553) 2022-08-05 06:25:57 -04:00
Chris Allen
7cbbd9188e
Add support for AT TIME ZONE (#539)
* Support for empty array literals

* Added support for AT TIME ZONE

Co-authored-by: Chris Allen <chrisa@indeed.com>
2022-07-18 13:03:01 -04:00
5tan
dea7666086
Boxed Query body to save some stack space (#540) 2022-07-16 07:22:45 -04:00
Andrey Frolov
f29ce10a1a
Distinguish between INT and INTEGER types (#525)
* support integer

* fmt

* Update src/ast/data_type.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2022-06-21 09:32:10 -04:00
Dmitry Patsura
3f1c6426f0
feat: Initial support for DECLARE (cursors) (#509) 2022-06-06 07:22:12 -04:00