Skip to content

Commit 2338536

Browse files
committed
UNPICK revert empty df check
1 parent cf11052 commit 2338536

2 files changed

Lines changed: 4 additions & 43 deletions

File tree

python/tests/test_dataframe.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,6 @@ def test_filter(df):
252252
assert result.column(2) == pa.array([5])
253253

254254

255-
def test_show_empty(df, capsys):
256-
df_empty = df.filter(column("a") > literal(3))
257-
df_empty.show()
258-
captured = capsys.readouterr()
259-
assert "DataFrame has no rows" in captured.out
260-
261-
262255
def test_sort(df):
263256
df = df.sort(column("b").sort(ascending=False))
264257

@@ -2664,32 +2657,3 @@ def trigger_interrupt():
26642657

26652658
# Make sure the interrupt thread has finished
26662659
interrupt_thread.join(timeout=1.0)
2667-
2668-
2669-
def test_show_from_empty_rows(capsys):
2670-
"""Create a DataFrame with a valid schema but zero rows and call show().
2671-
2672-
This verifies that showing an empty-but-schema'd DataFrame does not panic
2673-
and prints a helpful message instead.
2674-
"""
2675-
# duplicate of test_show_empty; covered elsewhere
2676-
pass
2677-
2678-
2679-
def test_select_where_no_rows(capsys):
2680-
"""Create a DataFrame a:[1,2,3], filter with a>4 to produce zero rows and call show().
2681-
2682-
This verifies that a query returning zero rows does not trigger a panic and
2683-
instead prints a helpful message.
2684-
"""
2685-
# duplicate of test_show_empty; covered elsewhere
2686-
pass
2687-
2688-
2689-
def test_sql_select_where_no_rows(capsys):
2690-
"""Register a table 't' with a:[1,2,3], run SQL that returns no rows, and call show().
2691-
2692-
Ensures SQL path that returns zero rows doesn't panic when showing results.
2693-
"""
2694-
# duplicate of test_show_empty; covered elsewhere
2695-
pass

src/dataframe.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -998,13 +998,10 @@ impl PyDataFrame {
998998
fn print_dataframe(py: Python, df: DataFrame) -> PyDataFusionResult<()> {
999999
// Get string representation of record batches
10001000
let batches = wait_for_future(py, df.collect())??;
1001-
let result = if batches.is_empty() {
1002-
"DataFrame has no rows".to_string()
1003-
} else {
1004-
match pretty::pretty_format_batches(&batches) {
1005-
Ok(batch) => format!("DataFrame()\n{batch}"),
1006-
Err(err) => format!("Error: {:?}", err.to_string()),
1007-
}
1001+
let batches_as_string = pretty::pretty_format_batches(&batches);
1002+
let result = match batches_as_string {
1003+
Ok(batch) => format!("DataFrame()\n{batch}"),
1004+
Err(err) => format!("Error: {:?}", err.to_string()),
10081005
};
10091006

10101007
// Import the Python 'builtins' module to access the print function

0 commit comments

Comments
 (0)