Purifies a statement, removing any dependencies on external state. See the section on [purification](crate#purification) in the crate documentation for details. Note that this doesn't handle CREATE MATERIALIZED VIEW, which is handled by [purify_create_materialized_view_options] instead. This could be made more consistent by a refactoring discussed here: <https://github.com/MaterializeInc/materia
(
catalog: impl SessionCatalog,
now: u64,
stmt: Statement<Aug>,
storage_configuration: &StorageConfiguration,
)
| 283 | /// This could be made more consistent by a refactoring discussed here: |
| 284 | /// <https://github.com/MaterializeInc/materialize/pull/23870#discussion_r1435922709> |
| 285 | pub async fn purify_statement( |
| 286 | catalog: impl SessionCatalog, |
| 287 | now: u64, |
| 288 | stmt: Statement<Aug>, |
| 289 | storage_configuration: &StorageConfiguration, |
| 290 | ) -> (Result<PurifiedStatement, PlanError>, Option<ClusterId>) { |
| 291 | match stmt { |
| 292 | Statement::CreateSource(stmt) => { |
| 293 | let cluster_id = stmt.in_cluster.as_ref().map(|cluster| cluster.id.clone()); |
| 294 | ( |
| 295 | purify_create_source(catalog, now, stmt, storage_configuration).await, |
| 296 | cluster_id, |
| 297 | ) |
| 298 | } |
| 299 | Statement::AlterSource(stmt) => ( |
| 300 | purify_alter_source(catalog, stmt, storage_configuration).await, |
| 301 | None, |
| 302 | ), |
| 303 | Statement::CreateSink(stmt) => { |
| 304 | let cluster_id = stmt.in_cluster.as_ref().map(|cluster| cluster.id.clone()); |
| 305 | ( |
| 306 | purify_create_sink(catalog, stmt, storage_configuration).await, |
| 307 | cluster_id, |
| 308 | ) |
| 309 | } |
| 310 | Statement::CreateTableFromSource(stmt) => ( |
| 311 | purify_create_table_from_source(catalog, stmt, storage_configuration).await, |
| 312 | None, |
| 313 | ), |
| 314 | o => ( |
| 315 | Err(internal_err!( |
| 316 | "unexpected statement type in purification: {:?}", |
| 317 | o |
| 318 | )), |
| 319 | None, |
| 320 | ), |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | /// Injects `DOC ON` comments into all Avro formats that are using a schema |
| 325 | /// registry by finding all SQL `COMMENT`s that are attached to the sink's |
no test coverage detected