This is an automated email from the ASF dual-hosted git repository.

timsaucer pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-python.git


The following commit(s) were added to refs/heads/main by this push:
     new f6261b0  add a test to capture the bug (#843)
f6261b0 is described below

commit f6261b05ce0d68489403fe966a464cdd7d24b3b5
Author: Michael J Ward <[email protected]>
AuthorDate: Sun Sep 22 12:42:22 2024 -0500

    add a test to capture the bug (#843)
---
 python/datafusion/tests/test_context.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/python/datafusion/tests/test_context.py 
b/python/datafusion/tests/test_context.py
index 4af00a3..ab86faa 100644
--- a/python/datafusion/tests/test_context.py
+++ b/python/datafusion/tests/test_context.py
@@ -372,6 +372,25 @@ def test_dataset_filter(ctx, capfd):
     assert result[0].column(1) == pa.array([-3])
 
 
+def test_dataset_count(ctx):
+    # `datafusion-python` issue: 
https://github.com/apache/datafusion-python/issues/800
+    batch = pa.RecordBatch.from_arrays(
+        [pa.array([1, 2, 3]), pa.array([4, 5, 6])],
+        names=["a", "b"],
+    )
+    dataset = ds.dataset([batch])
+    ctx.register_dataset("t", dataset)
+
+    # Testing the dataframe API
+    df = ctx.table("t")
+    assert df.count() == 3
+
+    # Testing the SQL API
+    count = ctx.sql("SELECT COUNT(*) FROM t")
+    count = count.collect()
+    assert count[0].column(0) == pa.array([3])
+
+
 def test_pyarrow_predicate_pushdown_is_null(ctx, capfd):
     """Ensure that pyarrow filter gets pushed down for `IsNull`"""
     # create a RecordBatch and register it as a pyarrow.dataset.Dataset


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to