comphead commented on code in PR #7732:
URL: https://github.com/apache/arrow-datafusion/pull/7732#discussion_r1350501245
##########
datafusion/expr/src/expr.rs:
##########
@@ -1646,4 +1728,89 @@ mod test {
Ok(())
}
+
+ #[test]
+ fn test_arithmetic_ops() {
+ assert_eq!(
+ format!("{}", lit(1u32).add(lit(2u32))),
+ "UInt32(1) + UInt32(2)"
+ );
+ assert_eq!(
+ format!("{}", lit(1u32).sub(lit(2u32))),
+ "UInt32(1) - UInt32(2)"
+ );
+ assert_eq!(
+ format!("{}", lit(1u32).mul(lit(2u32))),
+ "UInt32(1) * UInt32(2)"
+ );
+ assert_eq!(
+ format!("{}", lit(1u32).div(lit(2u32))),
+ "UInt32(1) / UInt32(2)"
+ );
+ assert_eq!(
+ format!("{}", lit(1u32).mod_(lit(2u32))),
+ "UInt32(1) % UInt32(2)"
+ );
+ assert_eq!(format!("{}", lit(1u32).neg()), "(- UInt32(1))");
+ }
+
+ #[test]
+ fn test_bitwise_ops() {
+ assert_eq!(
+ format!("{}", lit(1u32).bitwise_and(lit(2u32))),
+ "UInt32(1) & UInt32(2)"
+ );
+ assert_eq!(
+ format!("{}", lit(1u32).bitwise_or(lit(2u32))),
+ "UInt32(1) | UInt32(2)"
+ );
+ assert_eq!(
+ format!("{}", lit(1u32).bitwise_xor(lit(2u32))),
+ "UInt32(1) BIT_XOR UInt32(2)"
+ );
+ assert_eq!(
+ format!("{}", lit(1u32).bitwise_shift_left(lit(2u32))),
+ "UInt32(1) << UInt32(2)"
+ );
+ assert_eq!(
+ format!("{}", lit(1u32).bitwise_shift_right(lit(2u32))),
+ "UInt32(1) >> UInt32(2)"
+ );
+ }
+
+ #[test]
+ fn test_logical_ops() {
Review Comment:
awesome. In addition to planner test would be great to have same tests on
Dataframe level to prove operators returns correct values.
Update examples and factor out the common interface (to make sure new added
operator will be covered by all kind of syntaxes) can be done is follow up PR
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]