(&self, f: &mut std::fmt::Formatter)
| 125 | |
| 126 | impl std::fmt::Display for BinaryExpr { |
| 127 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { |
| 128 | // Put parentheses around child binary expressions so that we can see the difference |
| 129 | // between `(a OR b) AND c` and `a OR (b AND c)`. We only insert parentheses when needed, |
| 130 | // based on operator precedence. For example, `(a AND b) OR c` and `a AND b OR c` are |
| 131 | // equivalent and the parentheses are not necessary. |
| 132 | |
| 133 | fn write_child( |
| 134 | f: &mut std::fmt::Formatter, |
| 135 | expr: &dyn PhysicalExpr, |
| 136 | precedence: u8, |
| 137 | ) -> std::fmt::Result { |
| 138 | if let Some(child) = expr.downcast_ref::<BinaryExpr>() { |
| 139 | let p = child.op.precedence(); |
| 140 | if p == 0 || p < precedence { |
| 141 | write!(f, "({child})")?; |
| 142 | } else { |
| 143 | write!(f, "{child}")?; |
| 144 | } |
| 145 | } else { |
| 146 | write!(f, "{expr}")?; |
| 147 | } |
| 148 | |
| 149 | Ok(()) |
| 150 | } |
| 151 | |
| 152 | let precedence = self.op.precedence(); |
| 153 | write_child(f, self.left.as_ref(), precedence)?; |
| 154 | write!(f, " {} ", self.op)?; |
| 155 | write_child(f, self.right.as_ref(), precedence) |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | /// Invoke a boolean kernel on a pair of arrays |
nothing calls this directly
no test coverage detected