Plan one or more SQL statements against the given catalog. Handles NodeDB-specific syntax (UPSERT, `{ }` object literals) via pre-processing before handing to sqlparser.
(sql: &str, catalog: &dyn SqlCatalog)
| 72 | /// Handles NodeDB-specific syntax (UPSERT, `{ }` object literals) via |
| 73 | /// pre-processing before handing to sqlparser. |
| 74 | pub fn plan_sql(sql: &str, catalog: &dyn SqlCatalog) -> Result<Vec<SqlPlan>> { |
| 75 | // Array DDL/DML uses non-standard syntax that sqlparser-rs cannot |
| 76 | // accept. Intercept it before the standard preprocess pipeline. |
| 77 | if let Some(stmt) = try_parse_array_statement(sql)? { |
| 78 | return plan_array_statement(stmt, catalog); |
| 79 | } |
| 80 | let preprocessed = preprocess::preprocess(sql)?; |
| 81 | let effective_sql = preprocessed.as_ref().map_or(sql, |p| p.sql.as_str()); |
| 82 | let is_upsert = preprocessed.as_ref().is_some_and(|p| p.is_upsert); |
| 83 | let temporal = preprocessed |
| 84 | .as_ref() |
| 85 | .map(|p| p.temporal) |
| 86 | .unwrap_or_default(); |
| 87 | |
| 88 | let statements = parse_sql(effective_sql)?; |
| 89 | plan_statements(&statements, is_upsert, temporal, catalog) |
| 90 | } |
| 91 | |
| 92 | /// Plan SQL with bound parameters (prepared statement execution). |
| 93 | /// |
nothing calls this directly
no test coverage detected