code: def is_reduction(expr):
      
  
      def has_reduction(op):
          if getattr(op, '_reduction', False):
              return True
  
          for arg in op.args:
              if isinstance(arg, ir.ScalarExpr) and has_reduction(arg.op()):
                  return True
  
          return False
  
      return has_reduction(expr.op() if isinstance(expr, ir.Expr) else expr)
docs: Check whether an expression is a reduction or not
  
      Aggregations yield typed scalar expressions, since the result of an
      aggregation is a single value. When creating an table expression
      containing a GROUP BY equivalent, we need to be able to easily check
      that we are looking at the result of an aggregation.
  
      As an example, the expression we are looking at might be something
      like: foo.sum().log10() + bar.sum().log10()
  
      We examine the operator DAG in the expression to determine if there
      are aggregations present.
  
      A bound aggregation referencing a separate table is a "false
      aggregation" in a GROUP BY-type expression and should be treated a
      literal, and must be computed as a separate query and stored in a
      temporary variable (or joined, for bound aggregations with keys)
  
      Parameters
      ----------
      expr : ir.Expr
  
      Returns
      -------
      check output : bool