Commit graph

571 commits

Author SHA1 Message Date
mz
4452f9bad1
Support specifying ASC/DESC in index columns (#249)
...by reusing `OrderByExpr` for `columns` in `Statement::CreateIndex`.

This supports SQLite's indexed-column syntax https://www.sqlite.org/syntax/indexed-column.html

MSSQL's (`ON <object> ( column [ ASC | DESC ] [ ,...n ] )`)
https://docs.microsoft.com/en-us/sql/t-sql/statements/create-index-transact-sql?view=sql-server-ver15

And most of PostgreSQL syntax (except for opclass):
`( { column_name | ( expression ) } [ COLLATE collation ] [ opclass ] [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [, ...] )`
https://www.postgresql.org/docs/12/sql-createindex.html
2020-07-30 15:37:58 +03:00
mz
9e7e30282e
Support identifiers quoted with backticks in the MySQL dialect (#247)
Per https://dev.mysql.com/doc/refman/8.0/en/identifiers.html
MySQL historically supports `identifiers quoted in backticks`
in addition to the ANSI "quoting style" (assuming ANSI_QUOTES mode).
2020-07-30 04:22:29 +03:00
Nickolay Ponomarev
1337820c06
Merge pull request #245 from nickolay/cleanups
Minor code cleanups
2020-07-29 02:13:16 +03:00
Nickolay Ponomarev
a6e30b3fad Fix typo in JSONFILE serialization
Closes https://github.com/ballista-compute/sqlparser-rs/issues/237
2020-07-29 02:08:17 +03:00
Nickolay Ponomarev
9a2d86dcb5 Change CREATE INDEX serialization to not end with a semicolon 2020-07-29 02:08:17 +03:00
Nickolay Ponomarev
9371652446 Fix "unused stmt" warning in tests, with default features 2020-07-29 02:08:17 +03:00
Nickolay Ponomarev
3e880b599a Use consistent style for Display impls 2020-07-29 02:08:17 +03:00
Nickolay Ponomarev
d0db8a224b Run cargo fmt 2020-07-28 23:36:13 +03:00
mz
09ca14fe8e
Support dialect-specific auto-increment column options for MySQL and SQLite (#234)
In MySQL it's AUTO_INCREMENT
(see https://dev.mysql.com/doc/refman/8.0/en/create-table.html)
and in SQLite it's AUTOINCREMENT.

We use `ColumnOption::DialectSpecific(Vec<Token>)` to avoid adding a new variant for each vendor-specific column option.
2020-07-28 23:34:21 +03:00
Steven
8020b2e5f0
Add Postgres-specific PREPARE, EXECUTE and DEALLOCATE (#243)
Adds top-statements PREPARE, EXECUTE and DEALLOCATE for Postgres-specific feature prepared statement.
2020-07-28 12:01:52 +03:00
Daniël Heres
d2e4340a32
Support create or replace view/table (#239)
* Support create or replace table

* Support create or replace view

* Simplify create or replace table parser

* Add tests for create or replace external table and materialized view

* Formatting

* Address review comments

* Create error if we didn't see a (external) table or (materialized) view afer create or replace
2020-07-27 21:59:08 +02:00
Dandandan
f053383c71 Release 0.6.1 2020-07-20 18:20:08 +02:00
Daniël Heres
3a42b69b89
Release 0.6.0 (#232) 2020-07-20 18:14:46 +02:00
Daniël Heres
583f22b929
Remove PostgreSQL version of assert (#229)
Remove PostgreSQL procedural assert statement. This also simplifies code somewhat.
2020-07-17 13:20:49 +02:00
Daniël Heres
c24b0e01db
Implement ASSERT statement (#226)
As supported by PostgreSQL and BigQuery (with some differences between them)
2020-07-16 17:28:03 +02:00
Daniël Heres
5cab18963e
Add TPCH reggression tests (#221)
* Add TPC-H reggression tests
2020-07-14 21:48:07 +02:00
Max Countryman
f3b9edca28
update travis badge to point to actions status (#219)
* update travis badge to point to actions status

It seems Travis is currently not updating as expected, likely as a side effect of the repo moving. If we're comfortable leaning on Actions, then we can switch out the badge here and plan to remove Travis entirely. Alternatively we could reconfigure Travis to work with the new repo name.

* Refer to correct branch

Co-authored-by: Dandandan <danielheres@gmail.com>
2020-07-05 14:32:01 +02:00
Max Countryman
8cc7702a8c
update branch references to main (#215)
* update branch references to `main`

* ensure we point to ballista-compute

* update a couple of links to point to ballista-compute
2020-07-02 21:31:54 +02:00
Andy Grove
2a6d5f2b61
update cargo manifest (#214) 2020-06-28 09:52:52 -06:00
mz
a53f1d26ef
Support SQLite CREATE VIRTUAL TABLE (#209)
`CREATE VIRTUAL TABLE .. USING <module_name> (<module_args>)`

https://www.sqlite.org/lang_createvtab.html
2020-06-28 04:31:33 +03:00
mz
0c83e5d9e8
Support SQLite's WITHOUT ROWID in CREATE TABLE (#208)
Per https://sqlite.org/lang_createtable.html

Co-authored-by: mashuai <mashuai@bytedance.com>
2020-06-26 15:11:46 +03:00
Nickolay Ponomarev
0c82be5c3b Follow-up to the recent release (CHANGELOG and the bench crate) 2020-06-26 15:00:12 +03:00
Andy Grove
1946791302 (cargo-release) start next development iteration 0.5.2-alpha.0 2020-06-25 20:46:29 -06:00
Andy Grove
05f8992a2f (cargo-release) version 0.5.1 2020-06-25 20:46:18 -06:00
Daniël Heres
15d5f71646
Add CREATE TABLE AS support (#206)
We parse it as a regular `CREATE TABLE` statement
followed by an `AS <query>`, which is how BigQuery works:
https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_table_statement


ANSI SQL and PostgreSQL only support a plain list of columns
after the table name in a CTAS
    `CREATE TABLE t (a) AS SELECT a FROM foo`

We currently only allow specifying a full schema with data
types, or omitting it altogether.

https://www.postgresql.org/docs/12/sql-createtableas.html
https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#as-subquery-clause


Finally, when no schema is specified, we print empty parens after a
plain `CREATE TABLE t ();` as required by PostgreSQL, but skip them
in a CTAS: `CREATE TABLE t AS ...`. This affects serialization only,
the parser allows omitting the schema in a regular `CREATE TABLE` too
since the first release of the parser:
7d27abdfb4/src/sqlparser.rs (L325-L332)

Co-authored-by: Nickolay Ponomarev <asqueella@gmail.com>
2020-06-23 16:30:22 +03:00
Jovansonlee Cesar
26361fd854
Implement ALTER TABLE DROP COLUMN (#148)
This implements `DROP [ COLUMN ] [ IF EXISTS ] column_name [ CASCADE ]`
sub-command of `ALTER TABLE`, which is what PostgreSQL supports https://www.postgresql.org/docs/12/sql-altertable.html
(except for the RESTRICT option)

Co-authored-by: Nickolay Ponomarev <asqueella@gmail.com>
2020-06-16 23:39:52 +03:00
mz
faeb7d440a
Implement ALTER TABLE ADD COLUMN and RENAME (#203)
Based on sqlite grammar
https://www.sqlite.org/lang_altertable.html
2020-06-16 22:52:37 +03:00
Daniël Heres
fab6e28271
Output DataType capitalized (#202)
This makes it consistent with other output which also prints keywords capitalized.
2020-06-13 16:18:44 +03:00
Daniël Heres
b24dbe513c
Replace FromStr with normal parser function for FileFormat (#201)
The previous version accepted quoting file format keywords
(`STORED AS "TEXTFILE"`) and was inconsistent with the
way WindowFrameUnits was parsed.
2020-06-13 15:38:01 +03:00
Daniël Heres
68afa2a764
Make FileFormat case insensitive (#200) 2020-06-12 18:10:44 +03:00
Taehoon Moon
a0f076acda
Make the cli example print JSON (#197)
...via the new json_example feature - to make it easier to try out the parser without coding.
2020-06-12 16:38:59 +03:00
Daniël Heres
f4fbd9b6b3
Take slice as input for parse_keywords (#199) 2020-06-12 02:10:17 +03:00
Max Countryman
6cdd4a146d
Support general "typed string" literals (#187)
Fixes #168 by enabling `DATE` and other keywords to be used as
identifiers when not followed by a string literal.

A "typed string" is our term for generalized version of `DATE '...'`/`TIME '...'`/
`TIMESTAMP '...'` literals, represented as `TypedString { data_type, value }`
in the AST.

Unlike DATE/TIME/TIMESTAMP literals, this is a non-standard extension
supported by PostgreSQL at least.

This is a port of MaterializeInc/materialize#3146

Co-authored-by: Nikhil Benesch <nikhil.benesch@gmail.com>
Co-authored-by: Nickolay Ponomarev <asqueella@gmail.com>
2020-06-12 00:04:43 +03:00
Daniël Heres
34548e890b
Change Word::keyword to a enum (#193)
This improves performance and paves the way to future API enhancements as discussed in the PR https://github.com/andygrove/sqlparser-rs/pull/193
2020-06-11 22:00:35 +03:00
Nickolay Ponomarev
0fe3a8ec39
Use Token::EOF instead of Option<Token> (#195)
This simplifies codes slightly, removing the need deal with the EOF case explicitly.

The clone kludge in `_ => self.expected("date/time field",
Token::Word(w.clone())))` will become unnecessary once we stop using
a separate match for the keywords, as suggested in
https://github.com/andygrove/sqlparser-rs/pull/193#issuecomment-641607194
2020-06-10 14:05:17 +03:00
Taehoon Moon
2f1015339a
Add serde support to AST structs and enums (#196)
Apply serde to AST structs and enums to be serializable/deserializable.
serde support is optional, can be activated by feature named "serde".
2020-06-10 12:53:52 +03:00
Nickolay Ponomarev
d9a7491d9a Various follow-ups to recent pushes
- Update CHANGELOG
- Update `.gitignore` for the build directory of the benchmark crate
- Remove src/lib from the recently added benchmark crate per
  https://github.com/andygrove/sqlparser-rs/pull/190#pullrequestreview-425835379
2020-06-10 09:40:42 +03:00
Max Countryman
846c52f450
Allow omitting units after INTERVAL (#184)
Alter INTERVAL to support postgres syntax

This patch updates our INTERVAL implementation such that the Postgres
and Redshfit variation of the syntax is supported: namely that 'leading
field' is optional.

Fixes #177.
2020-06-10 09:32:13 +03:00
Daniël Heres
d842f495db
Add line and column number to TokenizerError (#194)
Addresses https://github.com/andygrove/sqlparser-rs/issues/179 for tokenize errors
2020-06-10 09:15:44 +03:00
Nickolay Ponomarev
10b0b7f884
Update CHANGELOG (#192)
Also remove a comment with a trailing space, which rustfmt doesn't like
2020-06-07 20:43:44 +03:00
Daniël Heres
a42121de52
Use binary search to speed up matching keywords (#191) 2020-06-07 20:25:10 +03:00
Max Countryman
af54eb02b2
Rework github actions, add code coverage (#186)
This reworks our GitHub Actions workflow to include code coverage via
tarpaulin.

Fixes #164.
2020-06-07 20:15:31 +03:00
Daniël Heres
6e6fae73a0
Add benchmarks using cargo bench / criterion (#190) 2020-06-07 16:46:55 +03:00
Daniël Heres
d32df527e6
Accept &str in Parse::parse_sql (#182)
It is more generic to accept a `&str` than a `String` in an API,
and avoids having to convert a string to a `String` when not
needed, avoiding a copy.
2020-06-03 23:31:41 +03:00
Daniël Heres
b4699bd4a7
Support bitwise and, or, xor (#181)
Operator precedence is coming from:

https://cloud.google.com/bigquery/docs/reference/standard-sql/operators
2020-06-03 19:02:05 +03:00
Daniël Heres
00dc490f72
Support the string concat operator (#178)
The selected precedence is based on BigQuery documentation, where it is equal to `*` and `/`:

https://cloud.google.com/bigquery/docs/reference/standard-sql/operators
2020-06-02 21:24:30 +03:00
Max Countryman
5f3c1bda01
Provide LISTAGG implementation (#174)
This patch provides an initial implemenation of LISTAGG[1]. Notably this
implemenation deviates from ANSI SQL by allowing both WITHIN GROUP and
the delimiter to be optional. We do so because Redshift SQL works this
way and this approach is ultimately more flexible.

Fixes #169.

[1] https://modern-sql.com/feature/listagg
2020-05-30 18:50:17 +03:00
QP Hou
418b9631ce
add nulls first/last support to order by expression (#176)
Following `<sort specification list>` from the standard https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#_10_10_sort_specification_list
2020-05-30 17:05:15 +03:00
Nickolay Ponomarev
c918ff042d
Merge pull request #173 from alex-dukhno/create-schema
Support `CREATE SCHEMA schema_name` and `DROP SCHEMA schema_name`.

Both ANSI SQL and Posgres define a number of options for the CREATE SCHEMA statement.
They also support including other CREATE statements as part of the schema definition,
rather than separate statements. This PR supports neither.
2020-05-28 21:05:34 +03:00
Alex Dukhno
91f769e460 added create and drop schema 2020-05-28 19:50:16 +03:00