Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions datafusion/tests/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2966,6 +2966,45 @@ async fn query_count_distinct() -> Result<()> {
Ok(())
}

#[tokio::test]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also add it, but ignore the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, maybe that would be better...

If I am able to fix the problem in the next few days perhaps I can just incorporate this change into the proper fix 😆

I'll leave this PR as a draft for now

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;

// this is incorrect: the results should also
// include a row for NULL (c1=NULL, count = 1)
// https://github.com/apache/arrow-datafusion/issues/782
let expected = vec![
"+-----------------+----+",
"| COUNT(UInt8(1)) | c1 |",
"+-----------------+----+",
"| 2 | 3 |",
"| 2 | 0 |",
"| 1 | 1 |",
"+-----------------+----+",
];
assert_batches_sorted_eq!(expected, &actual);
Ok(())
}

#[tokio::test]
async fn query_on_string_dictionary() -> Result<()> {
// Test to ensure DataFusion can operate on dictionary types
Expand Down