pub fn action(&self, relation: &mut MirRelationExpr) -> Result<(), crate::TransformError> {
        if let MirRelationExpr::Reduce {
            input,
            group_key,
            aggregates,
            monotonic: _,
            expected_group_size: _,
        } = relation
        {
            let input_type = input.typ();
            if input_type.keys.iter().any(|keys| {
                keys.iter()
                    .all(|k| group_key.contains(&expr::MirScalarExpr::Column(*k)))
            }) {
                let map_scalars = aggregates
                    .iter()
                    .map(|a| a.on_unique(&input_type))
                    .collect_vec();

                let mut result = input.take_dangerous();

                // Append the group keys, then any `map_scalars`, then project
                // to put them all in the right order.
                let mut new_scalars = group_key.clone();
                new_scalars.extend(map_scalars);
                result = result.map(new_scalars).project(
                    (input_type.column_types.len()
                        ..(input_type.column_types.len() + (group_key.len() + aggregates.len())))
                        .collect(),
                );

                *relation = result;
            }
        }
        Ok(())
    }
/// Removes `Reduce` when the input has as unique keys the keys of the reduce.
Removes `Reduce` when the input has as unique keys the keys of the reduce.
Removes ` Reduce ` when the input has as unique keys the keys of the reduce .
pub fn action(&self, relation: &mut MirRelationExpr) -> Result<(), crate::TransformError> {
        if let MirRelationExpr::Reduce {
            input,
            group_key,
            aggregates,
            monotonic: _,
            expected_group_size: _,
        } = relation
        {
            let input_type = input.typ();
            if input_type.keys.iter().any(|keys| {
                keys.iter()
                    .all(|k| group_key.contains(&expr::MirScalarExpr::Column(*k)))
            }) {
                let map_scalars = aggregates
                    .iter()
                    .map(|a| a.on_unique(&input_type))
                    .collect_vec();
                let mut result = input.take_dangerous();
                // Append the group keys, then any `map_scalars`, then project
                // to put them all in the right order.
                let mut new_scalars = group_key.clone();
                new_scalars.extend(map_scalars);
                result = result.map(new_scalars).project(
                    (input_type.column_types.len()
                        ..(input_type.column_types.len() + (group_key.len() + aggregates.len())))
                        .collect(),
                );
                *relation = result;
            }
        }
        Ok(())
    }
pub fn action ( & self , relation : & mut MirRelationExpr ) -> Result < ( ) , crate :: TransformError > { if let MirRelationExpr :: Reduce { input , group_key , aggregates , monotonic : _ , expected_group_size : _ , } = relation { let input_type = input . typ ( ) ; if input_type . keys . iter ( ) . any ( | keys | { keys . iter ( ) . all ( | k | group_key . contains ( & expr :: MirScalarExpr :: Column ( * k ) ) ) } ) { let map_scalars = aggregates . iter ( ) . map ( | a | a . on_unique ( & input_type ) ) . collect_vec ( ) ; let mut result = input . take_dangerous ( ) ; // Append the group keys, then any `map_scalars`, then project // to put them all in the right order. let mut new_scalars = group_key . clone ( ) ; new_scalars . extend ( map_scalars ) ; result = result . map ( new_scalars ) . project ( ( input_type . column_types . len ( ) .. ( input_type . column_types . len ( ) + ( group_key . len ( ) + aggregates . len ( ) ) ) ) . collect ( ) , ) ; * relation = result ; } } Ok ( ( ) ) }
Removes `Reduce` when the input has as unique keys the keys of the reduce.
Removes ` Reduce ` when the input has as unique keys the keys of the reduce .
&self
relation
&mut MirRelationExpr
&self
relation
&mut MirRelationExpr