You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by lu...@apache.org on 2026/09/22 14:22:44 UTC

(datafusion-sqlparser-rs) branch fix-eq-alias-assignment-from updated (2b4289c0e -> 7fe62eb3a)

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

LucaCappelletti94 pushed a change to branch fix-eq-alias-assignment-from
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git


 discard 2b4289c0e MsSql: Disallow unquoted FROM keyword as alias assignment expression
     new 7fe62eb3a MsSql: Disallow unquoted FROM keyword as alias assignment expression

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (2b4289c0e)
            \
             N -- N -- N   refs/heads/fix-eq-alias-assignment-from (7fe62eb3a)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

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.


Summary of changes:
 src/parser/mod.rs | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)


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


(datafusion-sqlparser-rs) 01/01: MsSql: Disallow unquoted FROM keyword as alias assignment expression

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

LucaCappelletti94 pushed a commit to branch fix-eq-alias-assignment-from
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git

commit 7fe62eb3aedf7332e0d7360fc7e4002170c978ce
Author: LucaCappelletti94 <ca...@gmail.com>
AuthorDate: Tue Sep 22 16:01:33 2026 +0200

    MsSql: Disallow unquoted FROM keyword as alias assignment expression
---
 src/parser/mod.rs         |  6 ++++++
 tests/sqlparser_common.rs | 18 ++++++++++++++++++
 tests/sqlparser_mssql.rs  |  5 +++++
 3 files changed, 29 insertions(+)

diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 74d97a085..b4f5f4268 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -19170,6 +19170,12 @@ impl<'a> Parser<'a> {
             } if self.dialect.supports_eq_alias_assignment()
                 && matches!(left.as_ref(), Expr::Identifier(_)) =>
             {
+                if matches!(right.as_ref(), Expr::Identifier(v) if v.value.to_lowercase() == "from" && v.quote_style.is_none()) {
+                    return parser_err!(
+                        format!("Expected an expression, found: {right}"),
+                        self.peek_token_ref().span.start
+                    );
+                }
                 let Expr::Identifier(alias) = *left else {
                     return parser_err!(
                         "BUG: expected identifier expression as alias",
diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs
index c4aa607d8..c6c482ba9 100644
--- a/tests/sqlparser_common.rs
+++ b/tests/sqlparser_common.rs
@@ -15232,6 +15232,24 @@ fn test_alias_equal_expr() {
     let expected = r#"SELECT (a * b) AS some_alias FROM some_table"#;
     let _ = dialects.one_statement_parses_to(sql, expected);
 
+    let sql = r#"SELECT some_alias = "from" FROM some_table"#;
+    let expected = r#"SELECT "from" AS some_alias FROM some_table"#;
+    let _ = dialects.one_statement_parses_to(sql, expected);
+
+    assert_eq!(
+        dialects
+            .parse_sql_statements("SELECT a = FROM")
+            .unwrap_err(),
+        ParserError::ParserError("Expected an expression, found: FROM".to_string())
+    );
+
+    assert_eq!(
+        dialects
+            .parse_sql_statements("SELECT a = FROM some_table")
+            .unwrap_err(),
+        ParserError::ParserError("Expected an expression, found: FROM".to_string())
+    );
+
     let dialects = all_dialects_where(|d| !d.supports_eq_alias_assignment());
     let sql = r#"SELECT x = (a * b) FROM some_table"#;
     let expected = r#"SELECT x = (a * b) FROM some_table"#;
diff --git a/tests/sqlparser_mssql.rs b/tests/sqlparser_mssql.rs
index 4510f953e..efde62c9d 100644
--- a/tests/sqlparser_mssql.rs
+++ b/tests/sqlparser_mssql.rs
@@ -2941,3 +2941,8 @@ fn parse_bracket_quoted_function_argument_name() {
         }])
     );
 }
+
+#[test]
+fn parse_bracket_quoted_eq_alias_assignment() {
+    ms().one_statement_parses_to("SELECT a = [from] FROM t", "SELECT [from] AS a FROM t");
+}


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