eliaperantoni commented on code in PR #13664: URL: https://github.com/apache/datafusion/pull/13664#discussion_r1931825255
########## datafusion/expr-common/src/type_coercion/binary.rs: ########## @@ -68,11 +70,57 @@ impl Signature { } } -/// Returns a [`Signature`] for applying `op` to arguments of type `lhs` and `rhs` -fn signature(lhs: &DataType, op: &Operator, rhs: &DataType) -> Result<Signature> { - use arrow::datatypes::DataType::*; - use Operator::*; - match op { +pub struct BinaryTypeCoercer<'a> { + lhs: &'a DataType, + op: &'a Operator, + rhs: &'a DataType, + + lhs_spans: Spans, + op_spans: Spans, + rhs_spans: Spans, +} + +impl<'a> BinaryTypeCoercer<'a> { + pub fn new(lhs: &'a DataType, op: &'a Operator, rhs: &'a DataType) -> Self { + Self { + lhs, + op, + rhs, + lhs_spans: Spans::new(), + op_spans: Spans::new(), + rhs_spans: Spans::new(), + } + } + + pub fn set_lhs_spans(&mut self, spans: Spans) { + self.lhs_spans = spans; + } + + pub fn set_op_spans(&mut self, spans: Spans) { + self.op_spans = spans; + } + + pub fn set_rhs_spans(&mut self, spans: Spans) { + self.rhs_spans = spans; + } + + fn span(&self) -> Span { + Span::union_iter( + [ + self.lhs_spans.first_or_empty(), Review Comment: Because in this scenario I expect the `Spans` to only have one element anyway, since we're looking at one expression in a binary expression. `Spans` can have multiple spans in other scenarios (e.g. if the `Column` comes out of a CTE with a `UNION`), but that's not expected here. I don't think it would make a difference to change it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org