Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2876,6 +2876,7 @@ pub enum PeerType {
Eventhubs,
PubSub,
Elasticsearch,
Clickhouse,
}

impl fmt::Display for PeerType {
Expand All @@ -2892,6 +2893,7 @@ impl fmt::Display for PeerType {
PeerType::Eventhubs => write!(f, "EVENTHUBS"),
PeerType::PubSub => write!(f, "PUBSUB"),
PeerType::Elasticsearch => write!(f, "ELASTICSEARCH"),
PeerType::Clickhouse => write!(f, "CLICKHOUSE"),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ define_keywords!(
CHARSET,
CHAR_LENGTH,
CHECK,
CLICKHOUSE,
CLOB,
CLONE,
CLOSE,
Expand Down
3 changes: 3 additions & 0 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9828,6 +9828,7 @@ impl<'a> Parser<'a> {
Keyword::EVENTHUBS,
Keyword::PUBSUB,
Keyword::ELASTICSEARCH,
Keyword::CLICKHOUSE,
]) {
Some(Keyword::BIGQUERY) => Ok(PeerType::Bigquery),
Some(Keyword::MONGO) => Ok(PeerType::Mongo),
Expand All @@ -9840,6 +9841,7 @@ impl<'a> Parser<'a> {
Some(Keyword::EVENTHUBS) => Ok(PeerType::Eventhubs),
Some(Keyword::PUBSUB) => Ok(PeerType::PubSub),
Some(Keyword::ELASTICSEARCH) => Ok(PeerType::Elasticsearch),
Some(Keyword::CLICKHOUSE) => Ok(PeerType::Clickhouse),
other => {
let supported_peer_types = [
"BIGQUERY",
Expand All @@ -9853,6 +9855,7 @@ impl<'a> Parser<'a> {
"EVENTHUBS",
"PUBSUB",
"ELASTICSEARCH",
"CLICKHOUSE",
];
let err = format!(
"expected peertype as one of {}, got {:#?}",
Expand Down
27 changes: 27 additions & 0 deletions tests/sqlparser_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3678,6 +3678,33 @@ fn parse_create_s3_peer() {
}
}

#[test]
fn parse_create_clickhouse_peer() {
match pg().verified_stmt(
"CREATE PEER clickhouse_1 FROM CLICKHOUSE WITH \
(host = 'http://clickhouse-server:8123')",
) {
Statement::CreatePeer {
if_not_exists: _,
peer_name: _,
peer_type,
with_options,
} => {
assert_eq!(peer_type, PeerType::Clickhouse);
assert_eq!(
with_options,
vec![SqlOption {
name: Ident::new("host"),
value: Expr::Value(Value::SingleQuotedString(String::from(
"http://clickhouse-server:8123"
)))
},]
);
}
_ => unreachable!(),
}
}

#[test]
fn parse_create_single_mirror() {
match pg().verified_stmt("CREATE MIRROR IF NOT EXISTS test_mirror FROM p1 TO p2 WITH TABLE MAPPING ({from : s1.t1, to : s2.t2}) WITH (key1 = 'value1')") {
Expand Down