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/21 10:58:40 UTC
(datafusion-sqlparser-rs) branch gh-readonly-queue/main/pr-2531-1195239663b48a51bf6b153f5d5150ec71042335 created (now 3fd342fe)
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-2531-1195239663b48a51bf6b153f5d5150ec71042335
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
at 3fd342fe PostgreSQL: Render prefix @ operator with a space (#2531)
This branch includes the following new commits:
new 3fd342fe PostgreSQL: Render prefix @ operator with a space (#2531)
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: PostgreSQL: Render prefix @ operator with a space (#2531)
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-2531-1195239663b48a51bf6b153f5d5150ec71042335
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
commit 3fd342fe823f8bd787b574adf3074d0b4da59b91
Author: Luca Cappelletti <ca...@gmail.com>
AuthorDate: Mon Sep 21 10:58:19 2026 +0000
PostgreSQL: Render prefix @ operator with a space (#2531)
---
src/ast/mod.rs | 1 +
tests/sqlparser_postgres.rs | 27 +++++++++++++++++++++------
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/src/ast/mod.rs b/src/ast/mod.rs
index 20058b83..b6d67df5 100644
--- a/src/ast/mod.rs
+++ b/src/ast/mod.rs
@@ -1964,6 +1964,7 @@ impl fmt::Display for Expr {
| UnaryOperator::Hash
| UnaryOperator::AtDashAt
| UnaryOperator::DoubleAt
+ | UnaryOperator::PGAbs
| UnaryOperator::QuestionDash
| UnaryOperator::QuestionPipe
) {
diff --git a/tests/sqlparser_postgres.rs b/tests/sqlparser_postgres.rs
index d71e49b2..c85cb26f 100644
--- a/tests/sqlparser_postgres.rs
+++ b/tests/sqlparser_postgres.rs
@@ -2623,13 +2623,13 @@ fn parse_ampersand_arobase() {
#[test]
fn parse_pg_unary_ops() {
let pg_unary_ops = &[
- ("|/", UnaryOperator::PGSquareRoot),
- ("||/", UnaryOperator::PGCubeRoot),
- ("!!", UnaryOperator::PGPrefixFactorial),
- ("@", UnaryOperator::PGAbs),
+ ("SELECT |/a", UnaryOperator::PGSquareRoot),
+ ("SELECT ||/a", UnaryOperator::PGCubeRoot),
+ ("SELECT !!a", UnaryOperator::PGPrefixFactorial),
+ ("SELECT @ a", UnaryOperator::PGAbs),
];
- for (str_op, op) in pg_unary_ops {
- let select = pg().verified_only_select(&format!("SELECT {}a", str_op));
+ for (sql, op) in pg_unary_ops {
+ let select = pg().verified_only_select(sql);
assert_eq!(
SelectItem::UnnamedExpr(Expr::UnaryOp {
op: *op,
@@ -9953,3 +9953,18 @@ fn parse_insert_by_name_keywords_as_table_and_alias() {
statement => panic!("Expected INSERT statement, got: {statement:?}"),
}
}
+
+#[test]
+fn parse_pg_abs_space_before_negative_operand() {
+ // `@-` tokenizes as a geometric operator prefix, so displaying PGAbs
+ // without a space breaks re-parsing of a negative operand.
+ pg().verified_stmt("SELECT @ -2");
+ pg().one_statement_parses_to("SELECT @a", "SELECT @ a");
+ let err = pg().parse_sql_statements("SELECT @-2").unwrap_err();
+ assert_eq!(
+ ParserError::TokenizerError(
+ "Expected a valid binary operator after '@-' at Line: 1, Column: 10".to_string(),
+ ),
+ err
+ );
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org