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

Method parse_table_from_source_option

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

Source from the content-addressed store, hash-verified

5185 }
5186
5187 fn parse_table_from_source_option(
5188 &mut self,
5189 ) -> Result<TableFromSourceOption<Raw>, ParserError> {
5190 let option = match self
5191 .expect_one_of_keywords(&[TEXT, EXCLUDE, IGNORE, DETAILS, PARTITION, RETAIN])?
5192 {
5193 ref keyword @ (TEXT | EXCLUDE) => {
5194 self.expect_keyword(COLUMNS)?;
5195
5196 let _ = self.consume_token(&Token::Eq);
5197
5198 let value = self
5199 .parse_option_sequence(Parser::parse_identifier)?
5200 .map(|inner| {
5201 WithOptionValue::Sequence(
5202 inner.into_iter().map(WithOptionValue::Ident).collect_vec(),
5203 )
5204 });
5205
5206 TableFromSourceOption {
5207 name: match *keyword {
5208 TEXT => TableFromSourceOptionName::TextColumns,
5209 EXCLUDE => TableFromSourceOptionName::ExcludeColumns,
5210 _ => unreachable!(),
5211 },
5212 value,
5213 }
5214 }
5215 DETAILS => TableFromSourceOption {
5216 name: TableFromSourceOptionName::Details,
5217 value: self.parse_optional_option_value()?,
5218 },
5219 IGNORE => {
5220 self.expect_keyword(COLUMNS)?;
5221 let _ = self.consume_token(&Token::Eq);
5222
5223 let value = self
5224 .parse_option_sequence(Parser::parse_identifier)?
5225 .map(|inner| {
5226 WithOptionValue::Sequence(
5227 inner.into_iter().map(WithOptionValue::Ident).collect_vec(),
5228 )
5229 });
5230 TableFromSourceOption {
5231 // IGNORE is historical syntax for this option.
5232 name: TableFromSourceOptionName::ExcludeColumns,
5233 value,
5234 }
5235 }
5236 PARTITION => {
5237 self.expect_keyword(BY)?;
5238 TableFromSourceOption {
5239 name: TableFromSourceOptionName::PartitionBy,
5240 value: self.parse_optional_option_value()?,
5241 }
5242 }
5243 RETAIN => {
5244 self.expect_keyword(HISTORY)?;

Callers

nothing calls this directly

Calls 8

expect_keywordMethod · 0.80
consume_tokenMethod · 0.80
parse_option_sequenceMethod · 0.80
mapMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected