mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-11 14:32:04 +00:00
Merge pull request #77 from benesch/count-distinct
Support COUNT(DISTINCT x) and similar
This commit is contained in:
commit
646479e56c
3 changed files with 65 additions and 4 deletions
|
@ -270,6 +270,14 @@ impl Parser {
|
|||
|
||||
pub fn parse_function(&mut self, name: SQLObjectName) -> Result<ASTNode, ParserError> {
|
||||
self.expect_token(&Token::LParen)?;
|
||||
let all = self.parse_keyword("ALL");
|
||||
let distinct = self.parse_keyword("DISTINCT");
|
||||
if all && distinct {
|
||||
return parser_err!(format!(
|
||||
"Cannot specify both ALL and DISTINCT in function: {}",
|
||||
name.to_string(),
|
||||
));
|
||||
}
|
||||
let args = self.parse_optional_args()?;
|
||||
let over = if self.parse_keyword("OVER") {
|
||||
// TBD: support window names (`OVER mywin`) in place of inline specification
|
||||
|
@ -296,7 +304,12 @@ impl Parser {
|
|||
None
|
||||
};
|
||||
|
||||
Ok(ASTNode::SQLFunction { name, args, over })
|
||||
Ok(ASTNode::SQLFunction {
|
||||
name,
|
||||
args,
|
||||
over,
|
||||
distinct,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn parse_window_frame(&mut self) -> Result<Option<SQLWindowFrame>, ParserError> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue