Commit graph

40 commits

Author SHA1 Message Date
Simon Sawert
b51f2a0c25
fix: Add support for MAX for NVARCHAR (#1232) 2024-04-26 13:56:37 -04:00
Ifeanyi Ubah
d2c2b15f9e
Add support for quoted string backslash escaping (#1177) 2024-04-21 09:07:56 -04:00
Lukasz Stefaniak
1cf6585649
SupportSELECT AS VALUE and SELECT AS STRUCT for BigQuery (#1135) 2024-02-29 07:14:00 -05:00
Joey Hain
2950a843c3
snowflake: fix rendering of SELECT TOP (#1070) 2023-12-22 13:43:31 -05:00
Ophir LOJKINE
c905ee0cb8
Support CONVERT expressions (#1048) 2023-11-20 14:55:18 -05:00
Ophir LOJKINE
953c833a4a
Support mssql json and xml extensions (#1043) 2023-11-18 07:03:12 -05:00
Ophir LOJKINE
ff8312bfd8
add support for MAX as a character length (#1038) 2023-11-10 15:57:56 -05:00
yuval-illumex
b89edaa98b
Support IGNORE|RESPECT NULLs clause in window functions (#998)
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2023-10-24 09:45:59 -04:00
Ophir LOJKINE
ce62fe6d27
Support FILTER in over clause (#1007)
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2023-10-23 18:06:39 -04:00
Lukasz Stefaniak
2786c7eaf1
clickhouse: add support for LIMIT BY (#977) 2023-10-02 11:53:32 -04:00
chunshao.rcs
f6e4be4c15
Support mysql partition to table selection (#959)
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2023-09-14 14:21:47 -04:00
Berkay Şahin
bb7b05e106
feat: Group By All (#964)
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2023-09-08 06:47:56 -04:00
Marko Grujic
1ea8858575
Table time travel clause support, add visit_table_factor to Visitor (#951) 2023-08-22 06:06:32 -04:00
Ophir LOJKINE
41e47cc013
add a test for mssql table name in square brackets (#952) 2023-08-21 13:21:45 -04:00
r.4ntix
a49ea1908d
feat: add ALTER ROLE syntax of PostgreSQL and MS SQL Server (#942) 2023-08-17 08:05:54 -04:00
Jeremy Maness
8bbb85356c
Fix SUBSTRING from/to argument construction for mssql (#947) 2023-08-17 06:17:57 -04:00
Andrew Lamb
4efe55dd8a
Remove most instances of #[cfg(feature(bigdecimal))] in tests (#910) 2023-07-17 14:19:51 -04:00
delsehi
f72b5a5d9b
Support basic CREATE PROCEDURE of MSSQL (#900)
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2023-06-22 11:09:14 -04:00
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
Aljaž Mur Eržen
0113bbd924
Test trailing commas (#859)
* test: add tests for trailing commas

* tweaks
2023-05-01 08:31:17 -04: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
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
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
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
TheSchemm
70ffa4166c
Support Parsing of hexadecimal literals that start with 0x (#324)
* Add support for 0x prefixed bin literal

* Add tests

* Fix formatting for test
2021-08-25 12:57:32 -04: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
Alex Kyllo
172ba42001 Add support for MSSQL's SELECT TOP N syntax (#150)
Add support for MSSQL SELECT TOP (N) [PERCENT] [WITH TIES] syntax.
2020-01-12 23:20:48 -05:00
Robert Grimm
b1cbc55128
Turn type Ident into struct Ident
The Ident type was previously an alias for a String. Turn it into a full
fledged struct, so that the parser can preserve the distinction between
identifier value and quote style already made by the tokenizer's Word
structure.
2019-10-20 00:16:41 -04:00
Nikhil Benesch
ac555d7e86
Remove "SQL" prefix from types
The rationale here is the same as the last commit: since this crate
exclusively parses SQL, there's no need to restate that in every type
name. (The prefix seems to be an artifact of this crate's history as a
submodule of Datafusion, where it was useful to explicitly call out
which types were related to SQL parsing.)

This commit has the additional benefit of making all type names
consistent; over type we'd added some types which were not prefixed with
"SQL".
2019-06-25 13:11:11 -04:00
Nikhil Benesch
cf655ad1a6
Remove "sql" prefix from module names
Since this crate only deals with SQL parsing, the modules are understood
to refer to SQL and don't need to restate that explicitly.
2019-06-24 12:56:26 -04:00
Nikhil Benesch
5b23ad1d4c
Merge pull request #119 from andygrove/astnode-expr
Rename ASTNode to Expr
2019-06-19 21:45:49 -04:00
Nikhil Benesch
646d1e13ca
Rename ASTNode to Expr
The ASTNode enum was confusingly named. In the past, the name made
sense, as the enum contained nearly all of the nodes in the AST, but
over time, pieces have been split into different structs, like
SQLStatement and SQLQuery. The ASTNode enum now contains only contains
expression nodes, so Expr is a better name.

Also rename the UnnamedExpression and ExpressionWithAlias variants
of SQLSelectItem to UnnamedExpr and ExprWithAlias, respectively, to
match the new shorthand for the word "expression".
2019-06-19 00:00:59 -04:00
Nickolay Ponomarev
4294581ded [mssql] Parse CROSS/OUTER APPLY
T-SQL (and Oracle) support non-standard syntax, which is similar in
functionality to LATERAL joins in ANSI and PostgreSQL
<https://blog.jooq.org/tag/lateral-derived-table/>: it allows to use
the columns from the tables defined to the left of `APPLY` in the
"derived tables" (subqueries) to the right of `APPLY`. Unlike ANSI
LATERAL (but like Postgres' implementation), APPLY is also used with
table-valued function calls.

Despite them being similar, we represent "APPLY" joins with
`JoinOperator`s of its own (`CrossApply` and `OuterApply`). Doing
otherwise seemed like it would cause unnecessary confusion, as those
interested in dialect-specific parsing would probably not expect APPLY
being parsed as LATERAL, and those wanting to forbid non-standard SQL
would not be helped by this either.

This also renames existing JoinOperator::Cross -> CrossJoin to avoid
confusion with CrossApply.
2019-06-19 02:45:47 +03:00
Andy Grove
b379480b7a
Merge pull request #79 from benesch/license
Standardize license headers
2019-06-10 19:39:12 -06:00
Nikhil Benesch
b841dccc2c
Properly handle mixed implicit and explicit joins
Parse a query like

    SELECT * FROM a NATURAL JOIN b, c NATURAL JOIN d

as the SQL specification requires, i.e.:

    from: [
        TableReference {
            relation: TableFactor::Table("a"),
            joins: [Join {
                relation: TableFactor::Table("b"),
                join_operator: JoinOperator::Natural,
            }]
        },
        TableReference {
            relation: TableFactor::Table("c"),
            joins: [Join {
                relation: TableFactor::Table("d"),
                join_operator: JoinOperator::Natural,
            }]
        }
    ]

Previously we were parsing such queries as

    relation: TableFactor::Table("a"),
    joins: [
        Join {
            relation: TableFactor::Table("b"),
            join_operator: JoinOperator::Natural,
        },
        Join {
            relation: TableFactor::Table("c"),
            join_operator: JoinOperator::Implicit,
        },
        Join {
            relation: TableFactor::Table("d"),
            join_operator: JoinOperator::Natural,
        },
    ]

which did not make the join hierarchy clear.
2019-06-10 11:11:25 -04:00
Nikhil Benesch
e78cf0483e
Standardize license headers
Standardize the license header, removing the Grove Enterprise copyright
notice where it exists per #58. Also add a CI check to ensure that files
without license headers don't get merged.

Fix #58.
2019-06-04 10:54:12 -04:00
Nickolay Ponomarev
93c9000102 [mssql] Support single-quoted column aliases 2019-06-02 13:48:14 +03:00
Nickolay Ponomarev
d0a782d8cc [mssql] Support delimited identifiers in [square brackets]
T-SQL supports non-standard `[...]` quoting in addition to the widely
supported and standard `"..."`:

https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers?view=sql-server-2017
2019-06-02 13:48:14 +03:00
Nickolay Ponomarev
67cc880fd1 Add comments to the test files 2019-05-04 02:43:00 +03:00
Nickolay Ponomarev
304710d59a Add MSSQL dialect and fix up the postgres' identifier rules
The `@@version` test is MS' dialect of SQL, it seems, so test it with
its own dialect.

Update the rules for identifiers in Postresql dialect per documentation,
while we're at it. The current identifier rules in Postgresql dialect
were introduced in this commit - as a copy of generic rules, it seems:
810cd8e6cf (diff-2808df0fba0aed85f9d35c167bd6a5f1L138)
2019-05-04 01:00:13 +03:00