MySQL: support for GROUP_CONCAT() (#1256)

This commit is contained in:
Joey Hain 2024-05-06 12:32:54 -07:00 committed by GitHub
parent d9d69a2192
commit c36e617d61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 0 deletions

View file

@ -4962,6 +4962,10 @@ pub enum FunctionArgumentClause {
///
/// See <https://trino.io/docs/current/functions/aggregate.html>.
OnOverflow(ListAggOnOverflow),
/// The `SEPARATOR` clause to the [`GROUP_CONCAT`] function in MySQL.
///
/// [`GROUP_CONCAT`]: https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat
Separator(Value),
}
impl fmt::Display for FunctionArgumentClause {
@ -4975,6 +4979,7 @@ impl fmt::Display for FunctionArgumentClause {
}
FunctionArgumentClause::Limit(limit) => write!(f, "LIMIT {limit}"),
FunctionArgumentClause::OnOverflow(on_overflow) => write!(f, "{on_overflow}"),
FunctionArgumentClause::Separator(sep) => write!(f, "SEPARATOR {sep}"),
}
}
}

View file

@ -616,6 +616,7 @@ define_keywords!(
SELECT,
SEMI,
SENSITIVE,
SEPARATOR,
SEQUENCE,
SEQUENCEFILE,
SEQUENCES,

View file

@ -9488,6 +9488,12 @@ impl<'a> Parser<'a> {
clauses.push(FunctionArgumentClause::Limit(self.parse_expr()?));
}
if dialect_of!(self is GenericDialect | MySqlDialect)
&& self.parse_keyword(Keyword::SEPARATOR)
{
clauses.push(FunctionArgumentClause::Separator(self.parse_value()?));
}
if let Some(on_overflow) = self.parse_listagg_on_overflow()? {
clauses.push(FunctionArgumentClause::OnOverflow(on_overflow));
}