You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/09/07 10:58:37 UTC
(datafusion-sqlparser-rs) branch gh-readonly-queue/main/pr-2477-eb6142261b4ecfab9d1c5da03e4fc9615e3aab13 created (now 16cd3934)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-2477-eb6142261b4ecfab9d1c5da03e4fc9615e3aab13
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
at 16cd3934 Visit function clauses in source order (#2477)
This branch includes the following new commits:
new 16cd3934 Visit function clauses in source order (#2477)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org
(datafusion-sqlparser-rs) 01/01: Visit function clauses in source order (#2477)
Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-2477-eb6142261b4ecfab9d1c5da03e4fc9615e3aab13
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
commit 16cd393479caba03ed8752dc0c3dd0f394394d74
Author: Ophir LOJKINE <co...@ophir.dev>
AuthorDate: Mon Sep 7 10:58:12 2026 +0000
Visit function clauses in source order (#2477)
Co-authored-by: Andrew Lamb <an...@nerdnetworks.org>
---
src/ast/mod.rs | 16 ++++++++--------
src/ast/visitor.rs | 26 ++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/src/ast/mod.rs b/src/ast/mod.rs
index 9077bed2..20058b83 100644
--- a/src/ast/mod.rs
+++ b/src/ast/mod.rs
@@ -8209,6 +8209,14 @@ pub struct Function {
/// The arguments to the function, including any options specified within the
/// delimiting parentheses.
pub args: FunctionArguments,
+ /// A clause used with certain aggregate functions to control the ordering
+ /// within grouped sets before the function is applied.
+ ///
+ /// Syntax:
+ /// ```plaintext
+ /// <aggregate_function>(expression) WITHIN GROUP (ORDER BY key [ASC | DESC], ...)
+ /// ```
+ pub within_group: Vec<OrderByExpr>,
/// e.g. `x > 5` in `COUNT(x) FILTER (WHERE x > 5)`
pub filter: Option<Box<Expr>>,
/// Indicates how `NULL`s should be handled in the calculation.
@@ -8222,14 +8230,6 @@ pub struct Function {
pub null_treatment: Option<NullTreatment>,
/// The `OVER` clause, indicating a window function call.
pub over: Option<WindowType>,
- /// A clause used with certain aggregate functions to control the ordering
- /// within grouped sets before the function is applied.
- ///
- /// Syntax:
- /// ```plaintext
- /// <aggregate_function>(expression) WITHIN GROUP (ORDER BY key [ASC | DESC], ...)
- /// ```
- pub within_group: Vec<OrderByExpr>,
}
impl fmt::Display for Function {
diff --git a/src/ast/visitor.rs b/src/ast/visitor.rs
index 41b70320..c78ff2bf 100644
--- a/src/ast/visitor.rs
+++ b/src/ast/visitor.rs
@@ -1243,6 +1243,32 @@ mod tests {
assert_eq!(visitor.idents, vec!["a", "b", "t"]);
}
+ #[test]
+ fn visits_function_clauses_in_source_order() {
+ #[derive(Default)]
+ struct ExprVisitor {
+ idents: Vec<String>,
+ }
+
+ impl Visitor for ExprVisitor {
+ type Break = ();
+
+ fn pre_visit_expr(&mut self, expr: &Expr) -> ControlFlow<Self::Break> {
+ if let Expr::Identifier(ident) = expr {
+ self.idents.push(ident.value.clone());
+ }
+ ControlFlow::Continue(())
+ }
+ }
+
+ let mut visitor = ExprVisitor::default();
+ do_visit(
+ "SELECT LISTAGG(value) WITHIN GROUP (ORDER BY order_key) FILTER (WHERE filter_key)",
+ &mut visitor,
+ );
+ assert_eq!(visitor.idents, ["value", "order_key", "filter_key"]);
+ }
+
#[derive(Default)]
struct RelationVisitor {
relations: Vec<String>,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org