jecsand838 commented on code in PR #8349: URL: https://github.com/apache/arrow-rs/pull/8349#discussion_r2369130006
########## arrow-avro/src/reader/record.rs: ########## @@ -1298,70 +926,28 @@ impl Decoder { ) -> Result<(), ArrowError> { match promotion { Promotion::Direct => self.decode(buf), - Promotion::IntToLong => match self { - Self::Int64(v) => { - v.push(buf.get_int()?.into()); - Ok(()) - } - _ => Err(ArrowError::ParseError( - "Promotion Int->Long target mismatch".into(), - )), - }, - Promotion::IntToFloat => match self { - Self::Float32(v) => { - v.push(buf.get_int()? as f32); - Ok(()) - } - _ => Err(ArrowError::ParseError( - "Promotion Int->Float target mismatch".into(), - )), - }, - Promotion::IntToDouble => match self { - Self::Float64(v) => { - v.push(buf.get_int()? as f64); - Ok(()) - } - _ => Err(ArrowError::ParseError( - "Promotion Int->Double target mismatch".into(), - )), - }, - Promotion::LongToFloat => match self { - Self::Float32(v) => { - v.push(buf.get_long()? as f32); - Ok(()) - } - _ => Err(ArrowError::ParseError( - "Promotion Long->Float target mismatch".into(), - )), - }, - Promotion::LongToDouble => match self { - Self::Float64(v) => { - v.push(buf.get_long()? as f64); - Ok(()) - } - _ => Err(ArrowError::ParseError( - "Promotion Long->Double target mismatch".into(), - )), - }, - Promotion::FloatToDouble => match self { - Self::Float64(v) => { - v.push(buf.get_float()? as f64); - Ok(()) - } - _ => Err(ArrowError::ParseError( - "Promotion Float->Double target mismatch".into(), - )), - }, + Promotion::IntToLong => promote_numeric!(self, buf, Int64, get_int, i64, promotion), + Promotion::IntToFloat => promote_numeric!(self, buf, Float32, get_int, f32, promotion), + Promotion::IntToDouble => promote_numeric!(self, buf, Float64, get_int, f64, promotion), + Promotion::LongToFloat => { + promote_numeric!(self, buf, Float32, get_long, f32, promotion) + } + Promotion::LongToDouble => { + promote_numeric!(self, buf, Float64, get_long, f64, promotion) Review Comment: Actually didn't realize you could do that. -- 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...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org