Parse a standalone SQL expression string into an `SqlExpr`. Used by the DEFAULT expression evaluator to handle arbitrary expressions (e.g. `upper('x')`, `1 + 2`) that don't match the hard-coded keyword list.
(expr_text: &str)
| 45 | /// Used by the DEFAULT expression evaluator to handle arbitrary expressions |
| 46 | /// (e.g. `upper('x')`, `1 + 2`) that don't match the hard-coded keyword list. |
| 47 | pub fn parse_expr_string(expr_text: &str) -> Result<SqlExpr> { |
| 48 | use sqlparser::dialect::GenericDialect; |
| 49 | use sqlparser::parser::Parser; |
| 50 | |
| 51 | let dialect = GenericDialect {}; |
| 52 | let ast_expr = Parser::new(&dialect) |
| 53 | .try_with_sql(expr_text) |
| 54 | .map_err(|e| SqlError::Parse { |
| 55 | detail: e.to_string(), |
| 56 | })? |
| 57 | .parse_expr() |
| 58 | .map_err(|e| SqlError::Parse { |
| 59 | detail: e.to_string(), |
| 60 | })?; |
| 61 | |
| 62 | resolver::expr::convert_expr(&ast_expr) |
| 63 | } |
| 64 | |
| 65 | use functions::registry::FunctionRegistry; |
| 66 | use parser::array_stmt::{ArrayStatement, try_parse_array_statement}; |
no test coverage detected