Skip to content

Conversation

@jonahgao
Copy link
Member

Which issue does this PR close?

Closes #8904.

Rationale for this change

When the query result does not contain rows, use the newly added schema parameter to create an empty batch and print column headers.

What changes are included in this PR?

Print column headers when query result contains no rows.

DataFusion CLI v37.1.0
> select * from (values (1)) where column1 = 2;
+---------+
| column1 |
+---------+
+---------+
0 row(s) fetched.
Elapsed 0.072 seconds.

Are these changes tested?

Yes

Are there any user-facing changes?

No

let df = ctx.sql("SHOW TABLES").await?;
let batches = df.collect().await?;
print_options.print_batches(&batches, now)
exec_and_print(ctx, print_options, "SHOW TABLES".into()).await
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
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.

lgtm thanks @jonahgao, now the empty output is more clear

@alamb alamb merged commit 0ea9bc6 into apache:main Apr 29, 2024
@jonahgao jonahgao deleted the print_empty branch April 30, 2024 01:33
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.

Improved output of datafuson-cli with empty results

3 participants