xo / usql

Universal command-line interface for SQL databases
MIT License
8.88k stars 347 forks source link

`\ss` says a relation is missing when a table is empty and doesn't have any statistics #364

Closed nineinchnick closed 1 year ago

nineinchnick commented 2 years ago
pg:postgres@localhost:5432/benchto=> \ss benchmark_runs
Did not find any relation named "benchmark_runs".
pg:postgres@localhost:5432/benchto=> select count(*) from benchmark_runs;
┌───────┐
│ count │
├───────┤
│     0 │
└───────┘

It would be more valuable if it printed a summary row with zeros.

kozikowskik commented 1 year ago

Hi @nineinchnick

It would be more valuable if it printed a summary row with zeros.

I wonder if a simple message like "Currently there are no statistics for xxx" won't be better? What do you think?

nineinchnick commented 1 year ago

How about a table with nulls? Having consistent output is important.

kozikowskik commented 1 year ago

Sorry, I think wasn't precise. I'm asking if it's not better to show a message instead of a summary with zeros if db hasn't returned any statistics for a table.

nineinchnick commented 1 year ago

When a database does not track statistics for all columns in a table, we should still show columns without statistics but with null values, not zeros. If there aren't any statistics for any column in a table, I'd still show this as a list of columns, because:

kozikowskik commented 1 year ago

Ok, thank you for the explanation.

nineinchnick commented 1 year ago

Fixed in eea1b686d381b705f979f966a8f6d76eb3da3737