diff --git a/src/ast/mod.rs b/src/ast/mod.rs index bf5c035..e47e429 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -2876,6 +2876,7 @@ pub enum PeerType { Eventhubs, PubSub, Elasticsearch, + Clickhouse, } impl fmt::Display for PeerType { @@ -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"), } } } diff --git a/src/keywords.rs b/src/keywords.rs index a3c32df..0b9cc03 100644 --- a/src/keywords.rs +++ b/src/keywords.rs @@ -147,6 +147,7 @@ define_keywords!( CHARSET, CHAR_LENGTH, CHECK, + CLICKHOUSE, CLOB, CLONE, CLOSE, diff --git a/src/parser/mod.rs b/src/parser/mod.rs index b7cebe0..087aee3 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -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), @@ -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", @@ -9853,6 +9855,7 @@ impl<'a> Parser<'a> { "EVENTHUBS", "PUBSUB", "ELASTICSEARCH", + "CLICKHOUSE", ]; let err = format!( "expected peertype as one of {}, got {:#?}", diff --git a/tests/sqlparser_postgres.rs b/tests/sqlparser_postgres.rs index cb701a4..53bc135 100644 --- a/tests/sqlparser_postgres.rs +++ b/tests/sqlparser_postgres.rs @@ -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')") {