(&mut self)
| 3161 | } |
| 3162 | |
| 3163 | fn parse_create_source(&mut self) -> Result<Statement<Raw>, ParserError> { |
| 3164 | self.expect_keyword(SOURCE)?; |
| 3165 | let if_not_exists = self.parse_if_not_exists()?; |
| 3166 | let name = self.parse_item_name()?; |
| 3167 | |
| 3168 | let (col_names, key_constraint) = self.parse_source_columns()?; |
| 3169 | |
| 3170 | let in_cluster = self.parse_optional_in_cluster()?; |
| 3171 | self.expect_keyword(FROM)?; |
| 3172 | |
| 3173 | // Webhook Source, which works differently than all other sources. |
| 3174 | if self.parse_keyword(WEBHOOK) { |
| 3175 | return self.parse_create_webhook_source(name, if_not_exists, in_cluster, false); |
| 3176 | } |
| 3177 | |
| 3178 | let connection = self.parse_create_source_connection()?; |
| 3179 | let format = match self.parse_one_of_keywords(&[KEY, FORMAT]) { |
| 3180 | Some(KEY) => { |
| 3181 | self.expect_keyword(FORMAT)?; |
| 3182 | let key = self.parse_format()?; |
| 3183 | self.expect_keywords(&[VALUE, FORMAT])?; |
| 3184 | let value = self.parse_format()?; |
| 3185 | Some(FormatSpecifier::KeyValue { key, value }) |
| 3186 | } |
| 3187 | Some(FORMAT) => Some(FormatSpecifier::Bare(self.parse_format()?)), |
| 3188 | Some(_) => unreachable!("parse_one_of_keywords returns None for this"), |
| 3189 | None => None, |
| 3190 | }; |
| 3191 | let include_metadata = self.parse_source_include_metadata()?; |
| 3192 | |
| 3193 | let envelope = if self.parse_keyword(ENVELOPE) { |
| 3194 | Some(self.parse_source_envelope()?) |
| 3195 | } else { |
| 3196 | None |
| 3197 | }; |
| 3198 | |
| 3199 | let referenced_subsources = if self.parse_keywords(&[FOR, TABLES]) { |
| 3200 | self.expect_token(&Token::LParen)?; |
| 3201 | let subsources = self.parse_comma_separated(Parser::parse_subsource_references)?; |
| 3202 | self.expect_token(&Token::RParen)?; |
| 3203 | Some(ExternalReferences::SubsetTables(subsources)) |
| 3204 | } else if self.parse_keywords(&[FOR, SCHEMAS]) { |
| 3205 | self.expect_token(&Token::LParen)?; |
| 3206 | let schemas = self.parse_comma_separated(Parser::parse_identifier)?; |
| 3207 | self.expect_token(&Token::RParen)?; |
| 3208 | Some(ExternalReferences::SubsetSchemas(schemas)) |
| 3209 | } else if self.parse_keywords(&[FOR, ALL, TABLES]) { |
| 3210 | Some(ExternalReferences::All) |
| 3211 | } else { |
| 3212 | None |
| 3213 | }; |
| 3214 | |
| 3215 | let progress_subsource = if self.parse_keywords(&[EXPOSE, PROGRESS, AS]) { |
| 3216 | Some(self.parse_deferred_item_name()?) |
| 3217 | } else { |
| 3218 | None |
| 3219 | }; |
| 3220 |
no test coverage detected