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

Function parse_statements

src/sql-parser/src/parser.rs:140–159  ·  view source on GitHub ↗
(sql: &str)

Source from the content-addressed store, hash-verified

138/// Parses a SQL string containing zero or more SQL statements.
139#[mz_ore::instrument(target = "compiler", level = "trace", name = "sql_to_ast")]
140pub fn parse_statements(sql: &str) -> Result<Vec<StatementParseResult<'_>>, ParserStatementError> {
141 let tokens = lexer::lex(sql).map_err(|error| ParserStatementError {
142 error: error.into(),
143 statement: None,
144 })?;
145 let res = Parser::new(sql, tokens).parse_statements();
146 // Don't trace sensitive raw sql, so we can only trace after parsing, and then can only output
147 // redacted statements.
148 debug!("{:?}", {
149 match &res {
150 Ok(stmts) => stmts
151 .iter()
152 .map(|stmt| stmt.ast.to_ast_string_redacted())
153 .join("; "),
154 // Errors can leak sensitive SQL.
155 Err(_) => "parse error".to_string(),
156 }
157 });
158 res
159}
160
161/// Parses a SQL string containing one SQL expression.
162pub fn parse_expr(sql: &str) -> Result<Expr<Raw>, ParserError> {

Callers 15

parse_statementFunction · 0.70
redact_sqlFunction · 0.50
parse_catalog_create_sqlFunction · 0.50
plan_alter_sinkFunction · 0.50
pretty_strsFunction · 0.50
pretty_strFunction · 0.50
verify_pretty_statementFunction · 0.50
assert_losslessFunction · 0.50
generate_view_sqlFunction · 0.50

Calls 2

parse_statementsMethod · 0.80
lexFunction · 0.50