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

Method parse_create_table

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

Source from the content-addressed store, hash-verified

5076 }
5077
5078 fn parse_create_table(&mut self) -> Result<Statement<Raw>, ParserError> {
5079 let temporary = self.parse_keyword(TEMPORARY) | self.parse_keyword(TEMP);
5080 self.expect_keyword(TABLE)?;
5081 let if_not_exists = self.parse_if_not_exists()?;
5082 let table_name = self.parse_item_name()?;
5083 // parse optional column list (schema)
5084 let (columns, constraints) = self.parse_columns(Mandatory)?;
5085
5086 let with_options = if self.parse_keyword(WITH) {
5087 self.expect_token(&Token::LParen)?;
5088 let o = if matches!(self.peek_token(), Some(Token::RParen)) {
5089 vec![]
5090 } else {
5091 self.parse_comma_separated(Parser::parse_table_option)?
5092 };
5093 self.expect_token(&Token::RParen)?;
5094 o
5095 } else {
5096 vec![]
5097 };
5098
5099 Ok(Statement::CreateTable(CreateTableStatement {
5100 name: table_name,
5101 columns,
5102 constraints,
5103 if_not_exists,
5104 temporary,
5105 with_options,
5106 }))
5107 }
5108
5109 fn parse_create_table_from_source(&mut self) -> Result<Statement<Raw>, ParserError> {
5110 if self.parse_keyword(TEMP) || self.parse_keyword(TEMPORARY) {

Callers 1

parse_createMethod · 0.80

Calls 8

parse_keywordMethod · 0.80
expect_keywordMethod · 0.80
parse_if_not_existsMethod · 0.80
parse_item_nameMethod · 0.80
parse_columnsMethod · 0.80
expect_tokenMethod · 0.80
parse_comma_separatedMethod · 0.80
CreateTableClass · 0.50

Tested by

no test coverage detected