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

Function split_identifier_string

src/sql-parser/src/parser.rs:213–227  ·  view source on GitHub ↗

Parses a string containing a comma-separated list of identifiers and returns their underlying string values. This is analogous to the `SplitIdentifierString` function in PostgreSQL.

(s: &str)

Source from the content-addressed store, hash-verified

211///
212/// This is analogous to the `SplitIdentifierString` function in PostgreSQL.
213pub fn split_identifier_string(s: &str) -> Result<Vec<String>, ParserError> {
214 // SplitIdentifierString ignores leading and trailing whitespace, and
215 // accepts empty input as a 0-length result.
216 if s.trim().is_empty() {
217 Ok(vec![])
218 } else {
219 let tokens = lexer::lex(s)?;
220 let mut parser = Parser::new(s, tokens);
221 let values = parser.parse_comma_separated(Parser::parse_set_variable_value)?;
222 Ok(values
223 .into_iter()
224 .map(|v| v.into_unquoted_value())
225 .collect())
226 }
227}
228
229macro_rules! maybe {
230 ($e:expr) => {{

Callers 1

parseMethod · 0.85

Calls 8

parse_comma_separatedMethod · 0.80
into_unquoted_valueMethod · 0.80
lexFunction · 0.50
is_emptyMethod · 0.45
trimMethod · 0.45
collectMethod · 0.45
mapMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected