diff --git a/datafusion/src/execution/context.rs b/datafusion/src/execution/context.rs index 393e4afdf865b..09755c73a2200 100644 --- a/datafusion/src/execution/context.rs +++ b/datafusion/src/execution/context.rs @@ -1399,79 +1399,6 @@ mod tests { Ok(()) } - #[tokio::test] - async fn sort() -> Result<()> { - let results = - execute("SELECT c1, c2 FROM test ORDER BY c1 DESC, c2 ASC", 4).await?; - assert_eq!(results.len(), 1); - - let expected: Vec<&str> = vec![ - "+----+----+", - "| c1 | c2 |", - "+----+----+", - "| 3 | 1 |", - "| 3 | 2 |", - "| 3 | 3 |", - "| 3 | 4 |", - "| 3 | 5 |", - "| 3 | 6 |", - "| 3 | 7 |", - "| 3 | 8 |", - "| 3 | 9 |", - "| 3 | 10 |", - "| 2 | 1 |", - "| 2 | 2 |", - "| 2 | 3 |", - "| 2 | 4 |", - "| 2 | 5 |", - "| 2 | 6 |", - "| 2 | 7 |", - "| 2 | 8 |", - "| 2 | 9 |", - "| 2 | 10 |", - "| 1 | 1 |", - "| 1 | 2 |", - "| 1 | 3 |", - "| 1 | 4 |", - "| 1 | 5 |", - "| 1 | 6 |", - "| 1 | 7 |", - "| 1 | 8 |", - "| 1 | 9 |", - "| 1 | 10 |", - "| 0 | 1 |", - "| 0 | 2 |", - "| 0 | 3 |", - "| 0 | 4 |", - "| 0 | 5 |", - "| 0 | 6 |", - "| 0 | 7 |", - "| 0 | 8 |", - "| 0 | 9 |", - "| 0 | 10 |", - "+----+----+", - ]; - - // Note it is important to NOT use assert_batches_sorted_eq - // here as we are testing the sortedness of the output - assert_batches_eq!(expected, &results); - - Ok(()) - } - - #[tokio::test] - async fn sort_empty() -> Result<()> { - // The predicate on this query purposely generates no results - let results = execute( - "SELECT c1, c2 FROM test WHERE c1 > 100000 ORDER BY c1 DESC, c2 ASC", - 4, - ) - .await - .unwrap(); - assert_eq!(results.len(), 0); - Ok(()) - } - #[tokio::test] async fn left_join_using() -> Result<()> { let results = execute( diff --git a/datafusion/tests/sql/mod.rs b/datafusion/tests/sql/mod.rs index 468762ea05bb2..d9088f51820fb 100644 --- a/datafusion/tests/sql/mod.rs +++ b/datafusion/tests/sql/mod.rs @@ -883,7 +883,7 @@ async fn nyc() -> Result<()> { }, _ => unreachable!(), }, - _ => unreachable!(false), + _ => unreachable!(), } Ok(()) diff --git a/datafusion/tests/sql/order.rs b/datafusion/tests/sql/order.rs index fa59d9d196615..d23c817789510 100644 --- a/datafusion/tests/sql/order.rs +++ b/datafusion/tests/sql/order.rs @@ -124,3 +124,77 @@ async fn test_specific_nulls_first_asc() -> Result<()> { assert_batches_eq!(expected, &actual); Ok(()) } + +#[tokio::test] +async fn sort() -> Result<()> { + let results = + partitioned_csv::execute("SELECT c1, c2 FROM test ORDER BY c1 DESC, c2 ASC", 4) + .await?; + assert_eq!(results.len(), 1); + + let expected: Vec<&str> = vec![ + "+----+----+", + "| c1 | c2 |", + "+----+----+", + "| 3 | 1 |", + "| 3 | 2 |", + "| 3 | 3 |", + "| 3 | 4 |", + "| 3 | 5 |", + "| 3 | 6 |", + "| 3 | 7 |", + "| 3 | 8 |", + "| 3 | 9 |", + "| 3 | 10 |", + "| 2 | 1 |", + "| 2 | 2 |", + "| 2 | 3 |", + "| 2 | 4 |", + "| 2 | 5 |", + "| 2 | 6 |", + "| 2 | 7 |", + "| 2 | 8 |", + "| 2 | 9 |", + "| 2 | 10 |", + "| 1 | 1 |", + "| 1 | 2 |", + "| 1 | 3 |", + "| 1 | 4 |", + "| 1 | 5 |", + "| 1 | 6 |", + "| 1 | 7 |", + "| 1 | 8 |", + "| 1 | 9 |", + "| 1 | 10 |", + "| 0 | 1 |", + "| 0 | 2 |", + "| 0 | 3 |", + "| 0 | 4 |", + "| 0 | 5 |", + "| 0 | 6 |", + "| 0 | 7 |", + "| 0 | 8 |", + "| 0 | 9 |", + "| 0 | 10 |", + "+----+----+", + ]; + + // Note it is important to NOT use assert_batches_sorted_eq + // here as we are testing the sortedness of the output + assert_batches_eq!(expected, &results); + + Ok(()) +} + +#[tokio::test] +async fn sort_empty() -> Result<()> { + // The predicate on this query purposely generates no results + let results = partitioned_csv::execute( + "SELECT c1, c2 FROM test WHERE c1 > 100000 ORDER BY c1 DESC, c2 ASC", + 4, + ) + .await + .unwrap(); + assert_eq!(results.len(), 0); + Ok(()) +} diff --git a/datafusion/tests/sql/partitioned_csv.rs b/datafusion/tests/sql/partitioned_csv.rs index 5efc837d5c95d..3394887ad0b83 100644 --- a/datafusion/tests/sql/partitioned_csv.rs +++ b/datafusion/tests/sql/partitioned_csv.rs @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -//! Utility functions for running with a partitioned csv dataset: +//! Utility functions for creating and running with a partitioned csv dataset. use std::{io::Write, sync::Arc};