Skip to content

fix: Prevent CLI crash on wide tables#21721

Merged
comphead merged 1 commit intoapache:mainfrom
Geethapranay1:fix-cli-crash-wide-table-21709
Apr 18, 2026
Merged

fix: Prevent CLI crash on wide tables#21721
comphead merged 1 commit intoapache:mainfrom
Geethapranay1:fix-cli-crash-wide-table-21709

Conversation

@Geethapranay1
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

The keep_only_maxrows function panics on wide tables, format string treats the spaces variable as an index and the new code repeats the space character directly. This prevents the format argument error.

What changes are included in this PR?

  • replaces the format string in keep_only_maxrows.
  • adds print_maxrows_limited_wide_table unit test.
  • adds test_cli_wide_result_set_no_crash integration test.
  • adds a wide result set snapshot file.

Are these changes tested?

Yes. I added unit and integration tests. The unit test passes a ten column schema to keep_only_maxrows and the integration test runs a wide query with a small row limit. These tests verify your format bug fix.

Are there any user-facing changes?

No

@Geethapranay1
Copy link
Copy Markdown
Contributor Author

Geethapranay1 commented Apr 18, 2026

@Dandandan, @comphead PR is ready for your review.

@Geethapranay1 Geethapranay1 force-pushed the fix-cli-crash-wide-table-21709 branch from 4044689 to 7cbd9a6 Compare April 18, 2026 17:36
Copy link
Copy Markdown
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

Thanks @Geethapranay1 I'm checking it on my example

@comphead
Copy link
Copy Markdown
Contributor

Okie, the test passes, nice work @Geethapranay1

Copy link
Copy Markdown
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

Thanks @Geethapranay1 I think the formatting needs to be fixed for CI

@Geethapranay1
Copy link
Copy Markdown
Contributor Author

fixing it now

@Geethapranay1 Geethapranay1 force-pushed the fix-cli-crash-wide-table-21709 branch from 7cbd9a6 to c6ac6be Compare April 18, 2026 18:40
Keep_only_maxrows panics on wide tables.
The format string treats the spaces variable as an index.
The new code repeats the space character directly.
This prevents the format argument error.

Closes apache#21709
@Geethapranay1 Geethapranay1 force-pushed the fix-cli-crash-wide-table-21709 branch from c6ac6be to 1402511 Compare April 18, 2026 18:40
@Geethapranay1
Copy link
Copy Markdown
Contributor Author

@comphead fixed the fmt!!

@comphead comphead added this pull request to the merge queue Apr 18, 2026
Merged via the queue into apache:main with commit b75df6f Apr 18, 2026
31 checks passed
Rich-T-kid pushed a commit to Rich-T-kid/datafusion that referenced this pull request Apr 21, 2026
## Which issue does this PR close?
 
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes apache#123` indicates that this PR will close issue apache#123.
-->

- Closes apache#21709 

## Rationale for this change

<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
The `keep_only_maxrows` function panics on wide tables, format string
treats the spaces variable as an index and the new code repeats the
space character directly. This prevents the format argument error.

## What changes are included in this PR?

<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->

- replaces the format string in `keep_only_maxrows`.
- adds `print_maxrows_limited_wide_table` unit test.
- adds `test_cli_wide_result_set_no_crash` integration test.
- adds a wide result set snapshot file.

## Are these changes tested?

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
Yes. I added unit and integration tests. The unit test passes a ten
column schema to `keep_only_maxrows` and the integration test runs a
wide query with a small row limit. These tests verify your format bug
fix.

## Are there any user-facing changes?
No
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->

<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
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.

Datafusion CLI crashes on large queries

2 participants