(
id_gen: &mut mz_ore::id_gen::IdGen,
outer: MirRelationExpr,
col_map: &ColumnMap,
cte_map: &mut CteMap,
subquery_expr: HirRelationExpr,
apply_requires_distinct_outer: bool,
| 2019 | } |
| 2020 | |
| 2021 | fn apply_existential_subquery( |
| 2022 | id_gen: &mut mz_ore::id_gen::IdGen, |
| 2023 | outer: MirRelationExpr, |
| 2024 | col_map: &ColumnMap, |
| 2025 | cte_map: &mut CteMap, |
| 2026 | subquery_expr: HirRelationExpr, |
| 2027 | apply_requires_distinct_outer: bool, |
| 2028 | context: &Context, |
| 2029 | ) -> Result<MirRelationExpr, PlanError> { |
| 2030 | branch( |
| 2031 | id_gen, |
| 2032 | outer, |
| 2033 | col_map, |
| 2034 | cte_map, |
| 2035 | subquery_expr, |
| 2036 | apply_requires_distinct_outer, |
| 2037 | context, |
| 2038 | |id_gen, expr, get_inner, col_map, cte_map, context| { |
| 2039 | let exists = expr |
| 2040 | // compute for every row in get_inner |
| 2041 | .applied_to(id_gen, get_inner.clone(), col_map, cte_map, context)? |
| 2042 | // throw away actual values and just remember whether or not there were __any__ rows |
| 2043 | .distinct_by((0..get_inner.arity()).collect()) |
| 2044 | // Append true to anything that returned any rows. |
| 2045 | .map(vec![MirScalarExpr::literal_true()]); |
| 2046 | |
| 2047 | // append False to anything that didn't return any rows |
| 2048 | get_inner.lookup(id_gen, exists, vec![(Datum::False, ReprScalarType::Bool)]) |
| 2049 | }, |
| 2050 | ) |
| 2051 | } |
| 2052 | |
| 2053 | impl AggregateExpr { |
| 2054 | fn applied_to( |
no test coverage detected