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/04/13 12:44:41 UTC

(datafusion-sqlparser-rs) branch gh-readonly-queue/main/pr-2294-1421b8758dc6d594bf6711fd96aa35df816fadc9 created (now b68aae0e)

This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a change to branch gh-readonly-queue/main/pr-2294-1421b8758dc6d594bf6711fd96aa35df816fadc9
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git


      at b68aae0e Fix COLLATE parsing after compound identifiers (#2294)

This branch includes the following new commits:

     new b68aae0e Fix COLLATE parsing after compound identifiers (#2294)

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: Fix COLLATE parsing after compound identifiers (#2294)

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch gh-readonly-queue/main/pr-2294-1421b8758dc6d594bf6711fd96aa35df816fadc9
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git

commit b68aae0eb43be54ae913384fb9c36fdc909db49f
Author: Roman Borschel <ro...@users.noreply.github.com>
AuthorDate: Mon Apr 13 14:44:17 2026 +0200

    Fix COLLATE parsing after compound identifiers (#2294)
    
    Co-authored-by: Roman Borschel <ro...@cluvio.com>
---
 src/parser/mod.rs        | 19 +++++++++++--------
 tests/sqlparser_mssql.rs |  5 +++++
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index caf2ff45..31e524f6 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -1397,6 +1397,16 @@ impl<'a> Parser<'a> {
 
         expr = self.parse_compound_expr(expr, vec![])?;
 
+        // Parse an optional collation cast operator following `expr`.
+        //
+        // For example (MSSQL): t1.a COLLATE Latin1_General_CI_AS
+        if !self.in_column_definition_state() && self.parse_keyword(Keyword::COLLATE) {
+            expr = Expr::Collate {
+                expr: Box::new(expr),
+                collation: self.parse_object_name(false)?,
+            };
+        }
+
         debug!("prefix: {expr:?}");
         loop {
             let next_precedence = self.get_next_precedence()?;
@@ -1962,14 +1972,7 @@ impl<'a> Parser<'a> {
             _ => self.expected_at("an expression", next_token_index),
         }?;
 
-        if !self.in_column_definition_state() && self.parse_keyword(Keyword::COLLATE) {
-            Ok(Expr::Collate {
-                expr: Box::new(expr),
-                collation: self.parse_object_name(false)?,
-            })
-        } else {
-            Ok(expr)
-        }
+        Ok(expr)
     }
 
     fn parse_geometric_type(&mut self, kind: GeometricTypeKind) -> Result<Expr, ParserError> {
diff --git a/tests/sqlparser_mssql.rs b/tests/sqlparser_mssql.rs
index 98609ae2..555a4cd2 100644
--- a/tests/sqlparser_mssql.rs
+++ b/tests/sqlparser_mssql.rs
@@ -2875,6 +2875,11 @@ fn parse_mssql_update_with_output_into() {
     );
 }
 
+#[test]
+fn test_collate_on_compound_identifier() {
+    ms_and_generic().verified_stmt("SELECT t1.a COLLATE Latin1_General_CI_AS FROM t1");
+}
+
 #[test]
 fn parse_mssql_money_constants() {
     ms().verified_only_select("SELECT CEILING($123.45)");


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org