-
Notifications
You must be signed in to change notification settings - Fork 609
Support parametric arguments to FUNCTION
for ClickHouse dialect
#1315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support parametric arguments to FUNCTION
for ClickHouse dialect
#1315
Conversation
@@ -4706,6 +4706,9 @@ impl fmt::Display for CloseCursor { | |||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))] | |||
pub struct Function { | |||
pub name: ObjectName, | |||
/// The parameters to the function, including any options specified within the | |||
/// delimiting parentheses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we include a link to the clickhouse docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iffyio Done
src/parser/mod.rs
Outdated
let mut parameters = FunctionArguments::None; | ||
// ClickHouse aggregation support parametric functions like `quantile(0.5)(x)` | ||
// which (0.5) is a parameter to the function. | ||
if dialect_of!(self is ClickHouseDialect) && self.consume_token(&Token::LParen) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if dialect_of!(self is ClickHouseDialect) && self.consume_token(&Token::LParen) { | |
if dialect_of!(self is ClickHouseDialect | GenericDialect) && self.consume_token(&Token::LParen) { |
we can include generic dialect if no conflicts
src/parser/mod.rs
Outdated
let args = self.parse_function_argument_list()?; | ||
let mut args = self.parse_function_argument_list()?; | ||
let mut parameters = FunctionArguments::None; | ||
// ClickHouse aggregation support parametric functions like `quantile(0.5)(x)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// ClickHouse aggregation support parametric functions like `quantile(0.5)(x)` | |
// ClickHouse aggregations support parametric functions like `quantile(0.5)(x)` |
tests/sqlparser_clickhouse.rs
Outdated
fn parse_select_parametric_function() { | ||
clickhouse().verified_stmt("SELECT quantile(0.5)(x) FROM t"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we extend the test asserting that the parameter and arguments lists do indeed show up in the parameters
and args
fields respectively (i.e not vice versa for example). Also we can include multiple items in both lists e.g quantile(0.5,0.6)(x,y)
@iffyio Thanks for your review, all comments are resolved now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! cc @alamb
FUNCTIONS
for ClickHouse dialect
FUNCTIONS
for ClickHouse dialectFUNCTION
for ClickHouse dialect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FUNCTION
for ClickHouse dialectFUNCTION
for ClickHouse dialect
} | ||
|
||
/// Parse any extra set expressions that may be present in a query body | ||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also pushed a commit to split up this function in e2ec2a6 to get the deeply nested tests to pass
This is the failure without this change: https://github.com/sqlparser-rs/sqlparser-rs/actions/runs/9632995493/job/26566863197
thread 'parse_deeply_nested_parens_hits_recursion_limits' has overflowed its stack
fatal runtime error: stack overflow
error: test failed, to rerun pass `--test sqlparser_common`
Pull Request Test Coverage Report for Build 9633078247Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Pull Request Test Coverage Report for Build 9633103403Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
This closes #1301