Skip to content

Commit 35f5f0b

Browse files
Redshift - Add support in sharp as start of the field name (#485)
* Add support in sharp * CR Review
1 parent ed86c6d commit 35f5f0b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/dialect/redshift.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ impl Dialect for RedshiftSqlDialect {
4444
}
4545

4646
fn is_identifier_start(&self, ch: char) -> bool {
47-
PostgreSqlDialect {}.is_identifier_start(ch)
47+
// Extends Postgres dialect with sharp
48+
PostgreSqlDialect {}.is_identifier_start(ch) || ch == '#'
4849
}
4950

5051
fn is_identifier_part(&self, ch: char) -> bool {
51-
PostgreSqlDialect {}.is_identifier_part(ch)
52+
// Extends Postgres dialect with sharp
53+
PostgreSqlDialect {}.is_identifier_part(ch) || ch == '#'
5254
}
5355
}

tests/sqlparser_redshift.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,13 @@ fn redshift() -> TestedDialects {
100100
dialects: vec![Box::new(RedshiftSqlDialect {})],
101101
}
102102
}
103+
104+
#[test]
105+
fn test_sharp() {
106+
let sql = "SELECT #_of_values";
107+
let select = redshift().verified_only_select(sql);
108+
assert_eq!(
109+
SelectItem::UnnamedExpr(Expr::Identifier(Ident::new("#_of_values"))),
110+
select.projection[0]
111+
);
112+
}

0 commit comments

Comments
 (0)