You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/07/29 18:06:45 UTC
[GitHub] [arrow-datafusion] Dandandan commented on a change in pull request #793: Produce correct answers for Group BY NULL (Option 1)
Dandandan commented on a change in pull request #793:
URL: https://github.com/apache/arrow-datafusion/pull/793#discussion_r679376098
##########
File path: datafusion/tests/sql.rs
##########
@@ -3014,6 +3014,109 @@ async fn query_count_distinct() -> Result<()> {
Ok(())
}
+#[tokio::test]
+async fn query_group_on_null() -> Result<()> {
+ let schema = Arc::new(Schema::new(vec![Field::new("c1", DataType::Int32, true)]));
+
+ let data = RecordBatch::try_new(
+ schema.clone(),
+ vec![Arc::new(Int32Array::from(vec![
+ Some(0),
+ Some(3),
+ None,
+ Some(1),
+ Some(3),
+ ]))],
+ )?;
+
+ let table = MemTable::try_new(schema, vec![vec![data]])?;
+
+ let mut ctx = ExecutionContext::new();
+ ctx.register_table("test", Arc::new(table))?;
+ let sql = "SELECT COUNT(*), c1 FROM test GROUP BY c1";
+
+ let actual = execute_to_batches(&mut ctx, sql).await;
+
+ // Note that the results also
+ // include a row for NULL (c1=NULL, count = 1)
+ let expected = vec![
+ "+-----------------+----+",
+ "| COUNT(UInt8(1)) | c1 |",
+ "+-----------------+----+",
+ "| 1 | |",
Review comment:
👍
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org