alamb commented on a change in pull request #9970:
URL: https://github.com/apache/arrow/pull/9970#discussion_r612351047



##########
File path: rust/datafusion/src/execution/context.rs
##########
@@ -1403,6 +1403,121 @@ mod tests {
         Ok(())
     }
 
+    #[tokio::test]
+    async fn aggregate_timestamps_sum() -> Result<()> {
+        let tmp_dir = TempDir::new()?;
+        let mut ctx = create_ctx(&tmp_dir, 1)?;
+        ctx.register_table("t", test::table_with_timestamps())
+            .unwrap();
+
+        let results = plan_and_collect(
+            &mut ctx,
+            "SELECT sum(nanos), sum(micros), sum(millis), sum(secs) FROM t",
+        )
+        .await
+        .unwrap_err();
+
+        assert_eq!(results.to_string(), "Error during planning: Coercion from 
[Timestamp(Nanosecond, None)] to the signature Uniform(1, [Int8, Int16, Int32, 
Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64]) failed.");
+
+        Ok(())
+    }
+
+    #[tokio::test]
+    async fn aggregate_timestamps_count() -> Result<()> {
+        let tmp_dir = TempDir::new()?;
+        let mut ctx = create_ctx(&tmp_dir, 1)?;
+        ctx.register_table("t", test::table_with_timestamps())
+            .unwrap();
+
+        let results = plan_and_collect(
+            &mut ctx,
+            "SELECT count(nanos), count(micros), count(millis), count(secs) 
FROM t",
+        )
+        .await
+        .unwrap();
+
+        let expected = vec![

Review comment:
       Thanks @velvia  --In general I agree that checking string 
representations in tests is brittle when formatting changes.
   
   In the case of sql / tabular output, I think it is the best alternative I 
have seen because:
   1. The output formatting does not change often
   2. Updating these tests are easy (simply copy/paste the output of the test 
failure into the test after verifying it)
   3. These tests follow the same pattern as the rest of the tests in this 
module
   
   




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to