Skip to content

Conversation

@juaby
Copy link
Owner

@juaby juaby commented Mar 4, 2021

Sync

alexkyllo and others added 30 commits January 12, 2020 23:20
Add support for MSSQL SELECT TOP (N) [PERCENT] [WITH TIES] syntax.
"iter.next() is equivalent to iter.nth(0), as they both consume the
next element, but is more readable."

https://rust-lang.github.io/rust-clippy/master/index.html#iter_nth_zero
Accept non-standard `Select * from (a)` queries, where the table name is inside parentheses.
MySQL doesn't support the ROWS part of OFFSET. Teach the parser to
remember which variant it saw, including just ROW.
Add support for OFFSET without the ROWS keyword (a MySQL quirk, documented at https://dev.mysql.com/doc/refman/8.0/en/select.html)

Teach the parser to remember which variant it saw (ROWS/ROW/none).
https://rust-lang.github.io/rust-clippy/master/index.html#single_component_path_imports
"Import with single component use path such as `use cratename;`
is not necessary, and thus should be removed."
...updated the TODOs regarding single-quoted literals parsing while at it.
Report an error on unterminated string literals (and more)
…lows

This should fix the build failures due to unavailable components, e.g.

error: component 'rustfmt' for target 'x86_64-unknown-linux-gnu' is unavailable for download for channel nightly
Sometimes not all components are available in any given nightly.
Adds support for the most common forms of CREATE INDEX, and for DROP INDEX:

	CREATE [ UNIQUE ] INDEX [ IF NOT EXISTS ]
	    <index_name>
	    ON <table_name>
	    ( col_name [, ...] )

	DROP INDEX <index_name>
Specifically, `FOREIGN KEY REFERENCES <foreign_table> (<referred_columns>)`
can now be followed by `ON DELETE <referential_action>` and/or by
`ON UPDATE <referential_action>`.
This was discussed in #125, but we forgot to update the README at the time.
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.
alex-dukhno and others added 29 commits September 30, 2020 05:29
This is a Postgres-specific clause: https://www.postgresql.org/docs/12/sql-createschema.html

Also add a test for `DROP SCHEMA IF EXISTS schema_name`, which is already supported in the parser.
SimpleLogger is private in v1.6. Bumping its version in Cargo.toml makes
`git pull && carg test` use the new version in an existing checkout
(with an existing Cargo.lock file referencing the old version)
Co-authored-by: Eyal Leshem <eyal@satoricyber.com>
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.
It was an omission of the original implementation.
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 #154
by (ab)using `TableFactor::NestedJoin` to represent anything nested in
extra set of parens.

Afterwards we learned in #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>
[snowflake] Support `FROM (table_name) alias`
…ease-config

add a note about cargo release config
Introduce support for EXPLAIN [ANALYZE] [VERBOSE] <STATEMENT> syntax
* Support analyze table

* Cleanup
* Parse floats without leading number

* Move period token test

* Comments

* Enable test
* feat: support parsing multiple show variables.

* fix: fix fmt error
@juaby juaby merged commit 8c40f3f into juaby:master Mar 4, 2021
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

Successfully merging this pull request may close these issues.