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

Method parse_create_webhook_source

src/sql-parser/src/parser.rs:3334–3419  ·  view source on GitHub ↗
(
        &mut self,
        name: UnresolvedItemName,
        if_not_exists: bool,
        in_cluster: Option<RawClusterName>,
        is_table: bool,
    )

Source from the content-addressed store, hash-verified

3332 }
3333
3334 fn parse_create_webhook_source(
3335 &mut self,
3336 name: UnresolvedItemName,
3337 if_not_exists: bool,
3338 in_cluster: Option<RawClusterName>,
3339 is_table: bool,
3340 ) -> Result<Statement<Raw>, ParserError> {
3341 self.expect_keywords(&[BODY, FORMAT])?;
3342
3343 // Note: we don't use `parse_format()` here because we support fewer formats than other
3344 // sources, and the user gets better errors if we reject the formats here.
3345 let body_format = match self.expect_one_of_keywords(&[JSON, TEXT, BYTES])? {
3346 JSON => {
3347 let array = self.parse_keyword(ARRAY);
3348 Format::Json { array }
3349 }
3350 TEXT => Format::Text,
3351 BYTES => Format::Bytes,
3352 _ => unreachable!(),
3353 };
3354
3355 let mut include_headers = CreateWebhookSourceIncludeHeaders::default();
3356 while self.parse_keyword(INCLUDE) {
3357 match self.expect_one_of_keywords(&[HEADER, HEADERS])? {
3358 HEADER => {
3359 let header_name = self.parse_literal_string()?;
3360 self.expect_keyword(AS)?;
3361 let column_name = self.parse_identifier()?;
3362 let use_bytes = self.parse_keyword(BYTES);
3363
3364 include_headers.mappings.push(CreateWebhookSourceMapHeader {
3365 header_name,
3366 column_name,
3367 use_bytes,
3368 });
3369 }
3370 HEADERS => {
3371 let header_filters = include_headers.column.get_or_insert_with(Vec::default);
3372 if self.consume_token(&Token::LParen) {
3373 let filters = self.parse_comma_separated(|f| {
3374 let block = f.parse_keyword(NOT);
3375 let header_name = f.parse_literal_string()?;
3376 Ok(CreateWebhookSourceFilterHeader { block, header_name })
3377 })?;
3378 header_filters.extend(filters);
3379
3380 self.expect_token(&Token::RParen)?;
3381 }
3382 }
3383 k => unreachable!("programming error, didn't expect {k}"),
3384 }
3385 }
3386
3387 let validate_using = if self.parse_keyword(CHECK) {
3388 self.expect_token(&Token::LParen)?;
3389
3390 let options = if self.parse_keyword(WITH) {
3391 self.expect_token(&Token::LParen)?;

Callers 2

parse_create_sourceMethod · 0.80

Calls 13

expect_keywordsMethod · 0.80
parse_keywordMethod · 0.80
parse_literal_stringMethod · 0.80
expect_keywordMethod · 0.80
parse_identifierMethod · 0.80
consume_tokenMethod · 0.80
parse_comma_separatedMethod · 0.80
expect_tokenMethod · 0.80
parse_exprMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected