waynexia commented on code in PR #5946:
URL: https://github.com/apache/arrow-datafusion/pull/5946#discussion_r1161823565


##########
datafusion/substrait/src/logical_plan/producer.rs:
##########
@@ -1285,3 +1283,62 @@ fn substrait_field_ref(index: usize) -> 
Result<Expression> {
         }))),
     })
 }
+
+#[cfg(test)]
+mod test {
+    use crate::logical_plan::consumer::from_substrait_literal;
+
+    use super::*;
+
+    #[test]
+    fn round_trip_literals() -> Result<()> {
+        round_trip_literal(ScalarValue::Boolean(None))?;

Review Comment:
   This should fail, I find I forget to match Boolean Null



##########
datafusion/substrait/src/logical_plan/producer.rs:
##########
@@ -1285,3 +1283,62 @@ fn substrait_field_ref(index: usize) -> 
Result<Expression> {
         }))),
     })
 }
+
+#[cfg(test)]
+mod test {
+    use crate::logical_plan::consumer::from_substrait_literal;
+
+    use super::*;
+
+    #[test]
+    fn round_trip_literals() -> Result<()> {
+        round_trip_literal(ScalarValue::Boolean(None))?;
+        round_trip_literal(ScalarValue::Boolean(Some(true)))?;
+        round_trip_literal(ScalarValue::Boolean(Some(false)))?;
+
+        round_trip_literal(ScalarValue::Int8(None))?;
+        round_trip_literal(ScalarValue::Int8(Some(i8::MIN)))?;
+        round_trip_literal(ScalarValue::Int8(Some(i8::MAX)))?;
+        round_trip_literal(ScalarValue::UInt8(None))?;
+        round_trip_literal(ScalarValue::UInt8(Some(u8::MIN)))?;
+        round_trip_literal(ScalarValue::UInt8(Some(u8::MAX)))?;
+
+        round_trip_literal(ScalarValue::Int16(None))?;
+        round_trip_literal(ScalarValue::Int16(Some(i16::MIN)))?;
+        round_trip_literal(ScalarValue::Int16(Some(i16::MAX)))?;
+        round_trip_literal(ScalarValue::UInt16(None))?;
+        round_trip_literal(ScalarValue::UInt16(Some(u16::MIN)))?;
+        round_trip_literal(ScalarValue::UInt16(Some(u16::MAX)))?;
+
+        round_trip_literal(ScalarValue::Int32(None))?;
+        round_trip_literal(ScalarValue::Int32(Some(i32::MIN)))?;
+        round_trip_literal(ScalarValue::Int32(Some(i32::MAX)))?;
+        round_trip_literal(ScalarValue::UInt32(None))?;
+        round_trip_literal(ScalarValue::UInt32(Some(u32::MIN)))?;
+        round_trip_literal(ScalarValue::UInt32(Some(u32::MAX)))?;
+
+        round_trip_literal(ScalarValue::Int64(None))?;
+        round_trip_literal(ScalarValue::Int64(Some(i64::MIN)))?;
+        round_trip_literal(ScalarValue::Int64(Some(i64::MAX)))?;
+        round_trip_literal(ScalarValue::UInt64(None))?;
+        round_trip_literal(ScalarValue::UInt64(Some(u64::MIN)))?;
+        round_trip_literal(ScalarValue::UInt64(Some(u64::MAX)))?;
+
+        Ok(())
+    }
+
+    fn round_trip_literal(scalar: ScalarValue) -> Result<()> {
+        println!("Checking round trip of {:?}", scalar);
+
+        let scalar = ScalarValue::Int32(Some(i32::MAX));

Review Comment:
   It shadows the input
   ```suggestion
   ```



-- 
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]

Reply via email to