Commit graph

581 commits

Author SHA1 Message Date
yuval-illumex
278345d21a
Add support of NVARCHAR data type (#462)
* Add support of nvarchar data type

* Change the format type with capitals

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

* Add Test

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2022-04-20 17:25:50 -04:00
slhmy
fd8f2df10d
Support Update Set From statement (#450) 2022-04-02 06:34:59 -04:00
Matthew Turner
803fd6c970
Add CREATE DATABASE test and parsing (#451)
* Add test

* Fix CreateDatabse parsing

* Linting

* Cleanup for code style
2022-04-01 13:32:38 -04:00
Maciej Obuchowski
d38c30e9ff
add SELECT INTO statement variation (#447)
Signed-off-by: Maciej Obuchowski <obuchowski.maciej@gmail.com>
2022-03-30 16:01:55 -04:00
Maciej Obuchowski
6b55e51101
add support for MERGE statement (#430)
* add support for MERGE statement

Signed-off-by: Maciej Obuchowski <obuchowski.maciej@gmail.com>

* fix lint errors

Signed-off-by: Maciej Obuchowski <obuchowski.maciej@gmail.com>
2022-03-12 14:28:57 -05:00
Yang Jiang
c688bbb4de
extract operator: add support for week keywords (#436) 2022-03-12 14:17:56 -05:00
Andrew Lamb
a28bbcd74c
Allow array to be used as a function name again (#432)
* Allow `array` to be used as a function

* clarify code, add docstrings

* fix docs

* cleanup

* fmt
2022-03-08 13:25:48 -05:00
Maciej Obuchowski
3af3ca07b6
extract operator: add support for Postgres keywords (#427)
Signed-off-by: Maciej Obuchowski <obuchowski.maciej@gmail.com>
2022-03-07 10:03:28 -05:00
Yoshiyuki Komazaki
0d1c5d1205
Support IN UNNEST(expression) (#426)
* feat: support `IN UNNEST(expression)`

* Add test for NOT IN UNNEST
2022-03-01 08:53:01 -05:00
gamife
0b5178d7e7
feat: add FOR UPDATE/FOR SHARE clause (#418)
* feat: add FOR UPDATE/FOR SHARE clause

* refactor: LockType enum variant name

Co-authored-by: gamife <gamife9886@gmail.com>
2022-02-24 06:39:38 +01:00
gamife
899f91b1f6
feat: add arg placeholder (#420)
Co-authored-by: gamife <gamife9886@gmail.com>
2022-02-17 07:55:21 -05:00
Andrew Lamb
d7f4f1aac9
Support MySQL style LIMIT X, Y (#415) 2022-02-09 06:44:51 -05:00
Andrew Lamb
ff558eeb61
Add Expr::tuple + parsing (#414) 2022-02-08 10:54:27 -05:00
Evgeny
8a3544abae
Fix panic with GRANT/REVOKE in CONNECT, CREATE, EXECUTE or TEMPORARY (#401)
* fix inconsistency between parse_grant_permissions and matched keywords

* Make it clear the error is an internal problem

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2022-02-08 10:50:55 -05:00
tvallotton
c4cbc8340a
Support DROP CONSTRAINT [ IF EXISTS ] <name> [ CASCADE ] (#396)
* adding support for DROP CONSTRAINT [ IF EXISTS ] <name>

* implementing [ CASCADE ] for DROP CONSTRAINT
2022-02-08 10:34:09 -05:00
Andrew Lamb
33d4f27bfc
Support OFFSET LIMIT as well as LIMIT OFFSET (#413)
* Inital support in current_timestamp

* Support time functions

* Add Test

* Fix order of offset

* Merge from main

* Fix PR

* Update Test

* Do not allow repeated LIMIT or OFFSET

Co-authored-by: Yuval Shkolar <yuval@illumex.ai>
2022-02-05 07:46:53 -05:00
Andrew Lamb
5cbf1e797a
Fix new clippy errors (#412) 2022-02-05 06:53:33 -05:00
yuval-illumex
fbc1d9659b
Support parentheses in DISTINCT clause, CURRENT_TIMESTAMP, CURRENT_TIME, and CURRENT_DATE (#391)
* Inital support in current_timestamp

* Support time functions

* Add Test

* Fix PR

* Fix tests

* Add Support for distinct with parentheses

* Fix nightly
2022-02-05 06:39:35 -05:00
Zach Hamlin
9569d1b215
feat: comment and alter column support (#381)
* feat: add support for postgresql comment keyword

* feat: add alter column and rename constraint
2021-12-17 12:19:08 -05:00
Taehoon Moon
823635d2fc
Add FunctionArgExpr and remove Expr::[Qualified]Wildcard, (#378)
* Add FunctionArgExpr and remove Expr::[Qualified]Wildcard,

There is no use case of `Expr::Wildcard` and `Expr::QualifiedWildcard` only except for function argments.
Add `FunctionArgExpr` to have `Wildcard` and `QualifiedWildcard`, and remove wildcards in `Expr`.

* Apply `FunctionArgExpr` to sqlparser_mysql tests
2021-12-15 06:35:37 -05:00
Poonai
4c121a92a6
support for session transaction and transaction snapshot. (#379)
* add support for snapshot id in set transaction

Signed-off-by: poonai <rbalajis25@gmail.com>

* add support for default session transaction characteristics

Signed-off-by: poonai <rbalajis25@gmail.com>

* add additional assertion for parse_set_transaction test

Signed-off-by: poonai <rbalajis25@gmail.com>

* Fix clippy

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2021-12-14 15:13:12 -05:00
Andrew Lamb
82eaae1522
Implement some MySQL specific syntax and extend the UPDATE statement (#375)
* * implement the ON DUPLICATE KEY syntax for MySQL in an INSERT statement

* * add MySQL to the cli example
* remove the dialect check for the ON DUPLICATE KEY insert to support
  custom dialects and unwrap some missing results

* * use the Assignment DataType for the ON DUPLICATE KEY UPDATE

* * add support for table aliases in an UPDATE statement
* add support for JOINS in an UPDATE statement (for MySQL)

* * implement the MySQL ALTER TABLE CHANGE COLUMN syntax

* * fix the formatting of the else * rename the parse_identifiers_strict
  to parse_identifiers_non_keywords

* Parse SUBSTRING calls that are separated with a comma instead of
keywords

* Fix the linting errors

Co-authored-by: Piotr <piotr.morawski@nc-vision.com>
Co-authored-by: Piotr Morawski <contact@peter-morawski.de>
2021-12-10 14:46:11 -05:00
Jiayu Liu
40d67aab87
parse grouping sets, rollup, and cube for postgresql (#366)
* parse grouping sets, rollup, and cube

* add postgresql flag
2021-12-10 14:45:09 -05:00
Ben Cook
d7e84be3e1
Add basic support for GRANT and REVOKE (#365)
* Add basic support for GRANT privileges on tables and sequences

* Cargo fmt

* Make enum for granted privileges

* Implement and use Display for GrantObjects

* Simplify Display for GrantPrivileges

* Add column privileges

* Add second column privilege to test

* Add REVOKE privileges and reformat

* Fix some clippy warnings

* Fix more clippy

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2021-12-08 15:55:23 -05:00
Daniël Heres
0f0b327e97
Implement is [not] distinct from (#361)
* Implement is [not] distinct from

* Simplify message

* Clippy
2021-10-14 18:26:28 +02:00
Qinxuan Chen
c9f8a44b55
Move the keywords module (#352)
* Move the keywords mod from dialect mod into the root of library

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* re-export keywords from dialect for backwards compatiblity

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
2021-09-26 07:59:39 -04:00
John
014b82f03d
Add logical xor (#357) 2021-09-18 06:39:35 -04:00
Dmitry Patsura
d2d4fc0c58
feat: Support DESCRIBE table_name (#340)
* feat: Support DESCRIBE

* feat: Support DESCRIBE table_name

* Update src/ast/mod.rs

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

* Update src/ast/mod.rs

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

* Update src/ast/mod.rs

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

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2021-09-09 11:49:33 -04:00
Alex Vasilev
77d90d3b85
Support minimum display width for integer data types (#337)
* Support minimum display width for integers

* make fmt happy, updated docstrings
2021-08-29 07:13:10 -04:00
joshwd36
a95c81fb13
Add referential actions to TableConstraint foreign key (#306)
* Add referential actions to TableConstraint foreign key

* Remove copy/paste error

* Add referential actions to TableConstraint foreign key

* Add additional tests
2021-08-25 12:03:10 -04:00
Jiseok CHOI
af1ac865b1
Add TrimWhereField for parse_trim_expr (#334)
* Remove Box from `trim_where`

* Add TrimWhereField for `parse_trim_expr`

* Add negative test case
2021-08-23 10:51:36 -04:00
Andy Grove
5ebc06b20c Update links to reflect repository move to sqlparser-rs GitHub org 2021-08-20 17:03:06 -06:00
Jiayu Liu
950daf39bb add default value for window frame 2021-08-20 13:55:53 -04:00
Jiseok CHOI
e548d38de8
Support TRIM syntax (#331)
* Support TRIM syntax

- Implement the following cases
- TRIM([BOTH | LEADING | TRAILING] <expr> [FROM <expr>])
- TRIM(<expr>)

* Resolve 1.54.0 clippy error

- Remove needless borrow

* Add test cases for TRIM
2021-08-20 08:53:52 +02:00
Qinxuan Chen
67e17b27f5
Make clippy happy (#330)
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
2021-08-19 23:02:15 +02:00
sundyli
e5991f3ae5
Support tinyint (#320)
* Support tinyint

* Add tests
2021-07-17 14:16:38 +02:00
Daniël Heres
d8775e2815
Fix linting errors (#318)
* Fix linting error

* Fix linting errors
2021-06-22 07:49:25 +02:00
BohuTANG
56e50dccd4
[parser] Return error instead of panic (#316)
* [parser] return error instead of panic

* Fix clippy warning

* Fix cargo fmt warning
2021-06-22 07:05:43 +02:00
Max Countryman
a9e6f77d62 provide ILIKE support
This introduces support for ILIKE and NOT ILIKE. ILIKE is the
case-insensitive variant of LIKE. Systems such as Postgres, Redshift,
and Snowflake provide this variant.[1][2][3]

[1] https://www.postgresql.org/docs/7.3/functions-matching.html
[2] https://docs.aws.amazon.com/redshift/latest/dg/r_patternmatching_condition_like.html
[3] https://docs.snowflake.com/en/sql-reference/functions/ilike.html
2021-03-22 07:31:42 -07:00
Mike Seddon
e6e37b47db
Implement TRY_CAST (#299)
Adds support for `TRY_CAST` and fixes a clippy error
2021-03-21 23:26:16 +01:00
zhangli-pear
add8991144
feat: support sqlite insert or statement (#281) 2021-02-09 21:04:54 +01:00
Daniël Heres
6f0b2dcd92
Implement SUBSTRING(col [FROM <expr>] [FOR <expr>]) syntax (#293) 2021-02-07 08:06:50 -07:00
Stephen Carman
8a214f9919
Implement Hive QL Parsing (#235) 2021-02-04 12:53:20 -07:00
Daniël Heres
94ff46802c
Support ANALYZE TABLE syntax (#285)
* Support analyze table

* Cleanup
2020-12-28 10:08:32 -07:00
Dmitry Patsura
17f2930885
Introduce support for EXPLAIN [ANALYZE] [VERBOSE] <STATEMENT> syntax
Introduce support for EXPLAIN [ANALYZE] [VERBOSE] <STATEMENT> syntax
2020-12-28 12:22:03 +01:00
Nickolay Ponomarev
929fc6764f
Merge pull request #260 from eyalleshem/single_tables_in_parens
[snowflake] Support `FROM (table_name) alias`
2020-10-13 09:59:38 +03:00
Nickolay Ponomarev
ad72cda6b0 [snowflake] Support specifying an alias after FROM (table_factor)
Snowflake diverges from the standard and from most of the other
implementations by allowing extra parentheses not only around a join,
but around lone table names (e.g. `FROM (mytable [AS alias])`) and
around derived tables (e.g. `FROM ((SELECT ...)  [AS alias])`) as well.

Initially this was implemented in https://github.com/ballista-compute/sqlparser-rs/issues/154
by (ab)using `TableFactor::NestedJoin` to represent anything nested in
extra set of parens.

Afterwards we learned in https://github.com/ballista-compute/sqlparser-rs/issues/223
that in cases of such extraneous nesting Snowflake allows specifying the
alias both inside and outside parens, but not both - consider:

    FROM (table_factor AS inner_alias) AS outer_alias

We've considered implementing this by changing `TableFactor::NestedJoin`
to a `TableFactor::Nested { inner: TableWithJoins, alias:
Option<TableAlias> }`, but that seemed too generic, as no known dialect
supports duplicate aliases, as shown above, nor naming nested joins
`(foo NATURAL JOIN bar) alias`. So we decided on making a smaller change
(with no modifications to the AST), that is also more appropriate to the
contributors to the Snowflake dialect:


1) Revert #154 by rejecting `FROM (table or derived table)` in most dialects.

2) For `dialect_of!(self is SnowflakeDialect | GenericDialect)` parse
and strip the extraneous parentheses, e.g.

   `(mytable) AS alias` -> `(mytable AS alias)`


Co-authored-by: Eyal Leshem <eyal@satoricyber.com>
2020-10-13 09:51:02 +03:00
Nickolay Ponomarev
4128dfe1db Introduce tests/test_utils/mod.rs and use it consistently
To share helper macros between various tests/* we added a new module
(tests/macros/mod.rs). This made the prologue to be used in tests quite
long and a little weird:
```
#[macro_use]
#[path = "macros/mod.rs"]
mod macros;
use sqlparser::test_utils::*;
```

This simplifies it to:
```
#[macro_use]
mod test_utils;
use test_utils::*;
```
- and switches all existing tests to the new prologue simultaneously...

...while fixing a few other inconsistencies and adding a few comments
about the way `test_utils` work.
2020-10-12 06:52:00 +03:00
rhanqtl
9f772f03b0
Add support for Recursive CTEs (#278)
i.e. `WITH RECURSIVE ... AS ( ... ) SELECT` - see https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#with-clause

Fixes #277
2020-10-11 09:43:51 +03:00
Nickolay Ponomarev
99fb633221 Move existing SF tests to sqlparser_snowflake.rs
Co-authored-by: Eyal Leshem <eyal@satoricyber.com>
2020-10-05 08:42:26 +03:00