mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-31 11:17:23 +00:00
Support SELECT ALL
Co-authored-by: Nikhil Benesch <nikhil.benesch@gmail.com>
This commit is contained in:
parent
4f944dd4aa
commit
55fc8c5a57
2 changed files with 18 additions and 0 deletions
|
@ -1300,7 +1300,11 @@ impl Parser {
|
|||
/// Parse a restricted `SELECT` statement (no CTEs / `UNION` / `ORDER BY`),
|
||||
/// assuming the initial `SELECT` was already consumed
|
||||
pub fn parse_select(&mut self) -> Result<SQLSelect, ParserError> {
|
||||
let all = self.parse_keyword("ALL");
|
||||
let distinct = self.parse_keyword("DISTINCT");
|
||||
if all && distinct {
|
||||
return parser_err!("Cannot specify both ALL and DISTINCT in SELECT");
|
||||
}
|
||||
let projection = self.parse_select_list()?;
|
||||
|
||||
let (relation, joins) = if self.parse_keyword("FROM") {
|
||||
|
|
|
@ -135,6 +135,20 @@ fn parse_select_distinct() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_select_all() {
|
||||
one_statement_parses_to("SELECT ALL name FROM customer", "SELECT name FROM customer");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_select_all_distinct() {
|
||||
let result = parse_sql_statements("SELECT ALL DISTINCT name FROM customer");
|
||||
assert_eq!(
|
||||
ParserError::ParserError("Cannot specify both ALL and DISTINCT in SELECT".to_string()),
|
||||
result.unwrap_err(),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_select_wildcard() {
|
||||
let sql = "SELECT * FROM foo";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue