(&mut self)
| 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 { |
no test coverage detected