Skip to content

Commit 8578713

Browse files
committed
test: improve test_register_filtered_dataframe by removing redundant comments and assertions
1 parent d0c3163 commit 8578713

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

python/tests/test_view.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,31 @@
33
import pytest
44

55
def test_register_filtered_dataframe():
6-
# Create a new session context
76
ctx = SessionContext()
87

9-
# Create sample data as a dictionary
108
data = {
119
"a": [1, 2, 3, 4, 5],
1210
"b": [10, 20, 30, 40, 50]
1311
}
1412

15-
# Create a DataFrame from the dictionary
1613
df = ctx.from_pydict(data, "my_table")
1714

18-
# Filter the DataFrame (for example, keep rows where a > 2)
1915
df_filtered = df.filter(col("a") > literal(2))
2016
view = df_filtered.into_view()
2117

18+
assert view.kind == "view"
2219

23-
# Register the filtered DataFrame as a table called "view1"
2420
ctx.register_table("view1", view)
2521

26-
# Now run a SQL query against the registered table "view1"
2722
df_view = ctx.sql("SELECT * FROM view1")
2823

29-
# Collect the results (as a list of Arrow RecordBatches)
3024
results = df_view.collect()
3125

32-
# Convert results to a list of dictionaries for easier assertion
3326
result_dicts = [batch.to_pydict() for batch in results]
3427

35-
# Expected results
3628
expected_results = [
3729
{"a": [3, 4, 5], "b": [30, 40, 50]}
3830
]
3931

40-
# Assert the results match the expected results
4132
assert result_dicts == expected_results
4233

43-
assert view.kind == "view"

0 commit comments

Comments
 (0)