MCPcopy Create free account
hub / github.com/apache/datafusion / fmt_sql

Method fmt_sql

datafusion/physical-expr/src/expressions/binary.rs:588–612  ·  view source on GitHub ↗
(&self, f: &mut std::fmt::Formatter<'_>)

Source from the content-addressed store, hash-verified

586 }
587
588 fn fmt_sql(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
589 fn write_child(
590 f: &mut std::fmt::Formatter,
591 expr: &dyn PhysicalExpr,
592 precedence: u8,
593 ) -> std::fmt::Result {
594 if let Some(child) = expr.downcast_ref::<BinaryExpr>() {
595 let p = child.op.precedence();
596 if p == 0 || p < precedence {
597 write!(f, "(")?;
598 child.fmt_sql(f)?;
599 write!(f, ")")
600 } else {
601 child.fmt_sql(f)
602 }
603 } else {
604 expr.fmt_sql(f)
605 }
606 }
607
608 let precedence = self.op.precedence();
609 write_child(f, self.left.as_ref(), precedence)?;
610 write!(f, " {} ", self.op)?;
611 write_child(f, self.right.as_ref(), precedence)
612 }
613}
614
615/// Casts dictionary array to result type for binary numerical operators. Such operators

Callers 1

write_childMethod · 0.45

Calls 2

precedenceMethod · 0.80
as_refMethod · 0.45

Tested by

no test coverage detected