MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parse_create_connection

Method parse_create_connection

src/sql-parser/src/parser.rs:2587–2655  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

2585 }
2586
2587 fn parse_create_connection(&mut self) -> Result<Statement<Raw>, ParserError> {
2588 self.expect_keyword(CONNECTION)?;
2589 let if_not_exists = self.parse_if_not_exists()?;
2590 let name = self.parse_item_name()?;
2591 let expect_paren = match self.expect_one_of_keywords(&[FOR, TO])? {
2592 FOR => false,
2593 TO => true,
2594 _ => unreachable!(),
2595 };
2596 let connection_type = match self.expect_one_of_keywords(&[
2597 AWS, GCP, KAFKA, CONFLUENT, POSTGRES, SSH, SQL, MYSQL, ICEBERG,
2598 ])? {
2599 AWS => {
2600 if self.parse_keyword(PRIVATELINK) {
2601 CreateConnectionType::AwsPrivatelink
2602 } else if self.parse_keyword(GLUE) {
2603 self.expect_keywords(&[SCHEMA, REGISTRY])?;
2604 CreateConnectionType::GlueSchemaRegistry
2605 } else {
2606 CreateConnectionType::Aws
2607 }
2608 }
2609 GCP => CreateConnectionType::Gcp,
2610 KAFKA => CreateConnectionType::Kafka,
2611 CONFLUENT => {
2612 self.expect_keywords(&[SCHEMA, REGISTRY])?;
2613 CreateConnectionType::Csr
2614 }
2615 POSTGRES => CreateConnectionType::Postgres,
2616 SSH => {
2617 self.expect_keyword(TUNNEL)?;
2618 CreateConnectionType::Ssh
2619 }
2620 SQL => {
2621 self.expect_keyword(SERVER)?;
2622 CreateConnectionType::SqlServer
2623 }
2624 MYSQL => CreateConnectionType::MySql,
2625 ICEBERG => {
2626 self.expect_keyword(CATALOG)?;
2627 CreateConnectionType::IcebergCatalog
2628 }
2629 _ => unreachable!(),
2630 };
2631 if expect_paren {
2632 self.expect_token(&Token::LParen)?;
2633 }
2634 let values = self.parse_comma_separated(Parser::parse_connection_option_unified)?;
2635 if expect_paren {
2636 self.expect_token(&Token::RParen)?;
2637 }
2638
2639 let with_options = if self.parse_keyword(WITH) {
2640 self.expect_token(&Token::LParen)?;
2641 let options = self.parse_comma_separated(Parser::parse_create_connection_option)?;
2642 self.expect_token(&Token::RParen)?;
2643 options
2644 } else {

Callers 1

parse_createMethod · 0.80

Calls 8

expect_keywordMethod · 0.80
parse_if_not_existsMethod · 0.80
parse_item_nameMethod · 0.80
parse_keywordMethod · 0.80
expect_keywordsMethod · 0.80
expect_tokenMethod · 0.80
parse_comma_separatedMethod · 0.80

Tested by

no test coverage detected