Skip to content

Commit b1f2f27

Browse files
max-sixtyaljazerzen
authored andcommitted
feat: Add clickhouse dialect (#1090)
* feat: Add clickhouse dialect
1 parent 1be8999 commit b1f2f27

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

prql-compiler/src/ast/dialect.rs

+11
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ impl Dialect {
3838
Dialect::MsSql => Box::new(MsSqlDialect),
3939
Dialect::MySql => Box::new(MySqlDialect),
4040
Dialect::BigQuery => Box::new(BigQueryDialect),
41+
Dialect::ClickHouse => Box::new(ClickHouseDialect),
4142
_ => Box::new(GenericDialect),
4243
}
4344
}
@@ -53,6 +54,7 @@ pub struct GenericDialect;
5354
pub struct MySqlDialect;
5455
pub struct MsSqlDialect;
5556
pub struct BigQueryDialect;
57+
pub struct ClickHouseDialect;
5658

5759
pub trait DialectHandler {
5860
fn dialect(&self) -> Dialect;
@@ -89,6 +91,15 @@ impl DialectHandler for MySqlDialect {
8991
}
9092
}
9193

94+
impl DialectHandler for ClickHouseDialect {
95+
fn dialect(&self) -> Dialect {
96+
Dialect::ClickHouse
97+
}
98+
fn ident_quote(&self) -> char {
99+
'`'
100+
}
101+
}
102+
92103
impl DialectHandler for BigQueryDialect {
93104
fn dialect(&self) -> Dialect {
94105
Dialect::BigQuery

prql-compiler/src/lib.rs

+18
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,24 @@ take 20
14751475
"###);
14761476
}
14771477

1478+
#[test]
1479+
fn test_dialect_clickhouse() {
1480+
let query = r###"
1481+
prql dialect:clickhouse
1482+
1483+
from github_json
1484+
derive [event_type_dotted = `event.type`]
1485+
"###;
1486+
1487+
assert_display_snapshot!((compile(query).unwrap()), @r###"
1488+
SELECT
1489+
github_json.*,
1490+
github_json.`event.type` AS event_type_dotted
1491+
FROM
1492+
github_json
1493+
"###);
1494+
}
1495+
14781496
#[test]
14791497
#[ignore]
14801498
fn test_ident_escaping() {

0 commit comments

Comments
 (0)