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

Function parse_statement_list

src/mz-deploy/src/project/compiler.rs:1093–1101  ·  view source on GitHub ↗

Parse a list of SQL strings and downcast each to a specific statement type. Each string is parsed via [`parse_one_statement`], then passed through `parser` to extract the expected AST variant (e.g., `CreateIndexStatement`). Returns `Err(())` if any string fails to parse or has the wrong statement type.

(
    sql_statements: &[String],
    parser: fn(Statement<Raw>) -> Result<T, ()>,
)

Source from the content-addressed store, hash-verified

1091/// `parser` to extract the expected AST variant (e.g., `CreateIndexStatement`).
1092/// Returns `Err(())` if any string fails to parse or has the wrong statement type.
1093fn parse_statement_list<T>(
1094 sql_statements: &[String],
1095 parser: fn(Statement<Raw>) -> Result<T, ()>,
1096) -> Result<Vec<T>, ()> {
1097 sql_statements
1098 .iter()
1099 .map(|sql| parse_one_statement(sql).and_then(parser))
1100 .collect()
1101}
1102
1103/// Parse a cached main statement SQL string into the project's [`Statement`](crate::project::ast::Statement) enum.
1104///

Callers 1

Calls 4

parse_one_statementFunction · 0.85
collectMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected