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/03 15:14:09 UTC
(datafusion-sqlparser-rs) branch main updated: Preserve numeric compound field access display (#2463)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 0821cbdd Preserve numeric compound field access display (#2463)
0821cbdd is described below
commit 0821cbdd5cbdc27f9c7205466d357deef632c936
Author: Luca Cappelletti <ca...@gmail.com>
AuthorDate: Thu Sep 3 14:59:50 2026 +0000
Preserve numeric compound field access display (#2463)
Co-authored-by: Andrew Lamb <an...@nerdnetworks.org>
---
src/ast/mod.rs | 3 +++
tests/sqlparser_postgres.rs | 11 +++++++++++
2 files changed, 14 insertions(+)
diff --git a/src/ast/mod.rs b/src/ast/mod.rs
index 57627b24..6e1d3bf9 100644
--- a/src/ast/mod.rs
+++ b/src/ast/mod.rs
@@ -1487,6 +1487,9 @@ pub enum AccessExpr {
impl fmt::Display for AccessExpr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
+ AccessExpr::Dot(Expr::Value(value)) if matches!(value.value, Value::Number(_, _)) => {
+ write!(f, " . {value}")
+ }
AccessExpr::Dot(expr) => write!(f, ".{expr}"),
AccessExpr::Subscript(subscript) => write!(f, "[{subscript}]"),
}
diff --git a/tests/sqlparser_postgres.rs b/tests/sqlparser_postgres.rs
index 17f8343b..8887508a 100644
--- a/tests/sqlparser_postgres.rs
+++ b/tests/sqlparser_postgres.rs
@@ -9853,6 +9853,17 @@ fn parse_alter_table_constraint_check_no_inherit() {
pg_and_generic().verified_stmt("ALTER TABLE docs ADD CONSTRAINT c CHECK (id > 0) NO INHERIT");
}
+#[test]
+fn parse_compound_field_access_numeric_display() {
+ let sql = "SELECT * FROM t WHERE CASE WHEN a = 1 THEN b ELSE c END . 2";
+ let mut statements = pg().parse_sql_statements(sql).unwrap();
+ assert_eq!(statements.len(), 1);
+ let statement = statements.pop().unwrap();
+ let displayed = statement.to_string();
+ let reparsed = pg().parse_sql_statements(&displayed).unwrap();
+ assert_eq!(vec![statement], reparsed);
+}
+
#[test]
fn parse_non_reserved_keywords_as_table_alias() {
// PostgreSQL allows these keywords as explicit table aliases.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org