Attempt to reduce the internal [`MirScalarExpr`] into a simpler expression. The reduction happens on a separate thread, we also only wait for `WebhookValidation::MAX_REDUCE_TIME` before timing out and returning an error.
(&mut self)
| 1598 | /// The reduction happens on a separate thread, we also only wait for |
| 1599 | /// `WebhookValidation::MAX_REDUCE_TIME` before timing out and returning an error. |
| 1600 | pub async fn reduce_expression(&mut self) -> Result<(), &'static str> { |
| 1601 | let WebhookValidation { |
| 1602 | expression, |
| 1603 | relation_desc, |
| 1604 | .. |
| 1605 | } = self; |
| 1606 | |
| 1607 | // On a different thread, attempt to reduce the expression. |
| 1608 | let mut expression_ = expression.clone(); |
| 1609 | let desc_ = relation_desc.clone(); |
| 1610 | let reduce_task = mz_ore::task::spawn_blocking( |
| 1611 | || "webhook-validation-reduce", |
| 1612 | move || { |
| 1613 | let repr_col_types: Vec<ReprColumnType> = desc_ |
| 1614 | .typ() |
| 1615 | .column_types |
| 1616 | .iter() |
| 1617 | .map(ReprColumnType::from) |
| 1618 | .collect(); |
| 1619 | expression_.reduce(&repr_col_types); |
| 1620 | expression_ |
| 1621 | }, |
| 1622 | ); |
| 1623 | |
| 1624 | match tokio::time::timeout(Self::MAX_REDUCE_TIME, reduce_task).await { |
| 1625 | Ok(reduced_expr) => { |
| 1626 | *expression = reduced_expr; |
| 1627 | Ok(()) |
| 1628 | } |
| 1629 | Err(_) => Err("timeout"), |
| 1630 | } |
| 1631 | } |
| 1632 | } |
| 1633 | |
| 1634 | #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)] |
no test coverage detected