Skip to content

Conversation

kosiew
Copy link
Contributor

@kosiew kosiew commented Aug 22, 2025

Which issue does this PR close?

Rationale for this change

When calling show() on a DataFrame with no rows, the current output may be misleading or unclear. This PR enhances the user experience by providing a clear message indicating that the DataFrame has no rows. This makes debugging and usage more intuitive, especially in cases where filters or queries return empty results.

What changes are included in this PR?

  • Added a conditional check in print_dataframe to handle the case where DataFrame.collect() returns no batches.

  • If the DataFrame has no rows, output "DataFrame has no rows".

  • Added tests for various scenarios:

    • Showing an empty DataFrame after filtering.
    • Showing the result of a SELECT query that returns no rows.
    • Showing an empty record batch with defined schema.

Are these changes tested?

Yes, comprehensive tests have been added using capsys to verify the show() output under multiple empty DataFrame scenarios:

  • test_show_empty
  • test_show_select_where_no_rows
  • test_show_from_empty_batch

Are there any user-facing changes?

Yes:

  • When show() is called on an empty DataFrame, the output is now: DataFrame has no rows
  • This is a user-friendly message replacing a potentially confusing blank or improperly formatted output.

Copy link
Member

@timsaucer timsaucer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@timsaucer timsaucer merged commit 1ba8807 into apache:main Aug 25, 2025
17 checks passed
@kosiew
Copy link
Contributor Author

kosiew commented Aug 25, 2025

You're welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PanicException: index out of bounds: the len is 0 but the index is 0

2 participants