From fe42086204eb7e2f1bec4eb17a350a01a37d37ff Mon Sep 17 00:00:00 2001 From: Andrew Gazelka Date: Thu, 21 Nov 2024 09:02:53 -0800 Subject: [PATCH] Update test_sort.py --- src/daft-connect/src/translation/logical_plan/sort.rs | 6 ++++-- tests/connect/test_sort.py | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/daft-connect/src/translation/logical_plan/sort.rs b/src/daft-connect/src/translation/logical_plan/sort.rs index 15baccbcd8..695c4d5756 100644 --- a/src/daft-connect/src/translation/logical_plan/sort.rs +++ b/src/daft-connect/src/translation/logical_plan/sort.rs @@ -50,7 +50,8 @@ pub fn sort(sort: spark_connect::Sort) -> eyre::Result { // todo(correctness): is this correct? let is_descending = match direction { SortDirection::Unspecified => { - bail!("Unspecified sort direction is not yet supported") + // default to ascending order + false } SortDirection::Ascending => false, SortDirection::Descending => true, @@ -59,7 +60,8 @@ pub fn sort(sort: spark_connect::Sort) -> eyre::Result { // todo(correctness): is this correct? let tentative_sort_nulls_first = match null_ordering { NullOrdering::SortNullsUnspecified => { - bail!("Unspecified null ordering is not yet supported") + // default: match is_descending + is_descending } NullOrdering::SortNullsFirst => true, NullOrdering::SortNullsLast => false, diff --git a/tests/connect/test_sort.py b/tests/connect/test_sort.py index 653510db18..4e5a9548be 100644 --- a/tests/connect/test_sort.py +++ b/tests/connect/test_sort.py @@ -11,6 +11,7 @@ def test_sort(spark_session): df_sorted = df.sort(col("id").desc()) # Verify the DataFrame is sorted correctly - df_pandas = df.toPandas() - df_sorted_pandas = df_sorted.toPandas() - assert df_sorted_pandas["id"].equals(df_pandas["id"].sort_values(ascending=False).reset_index(drop=True)), "Data should be sorted in descending order" + actual = df_sorted.collect() + + expected = list(range(9, -1, -1)) + assert [row.id for row in actual] == expected