[Feature request] Set decimal precision for outputs
Firstly, my thanks for the best clickhouse command line client out there. Its syntax highlighting, auto-completes and multi-line editing make things so much easier than the clickhouse-client.
One of the main pain points in current output formats is arbitrary long floats, which makes the column width way larger than they should be and much less readable.
An option to set precision to fix number of decimals will be really very big improvement in my opinion. Something similar to numpy's set_printoptions(precision=4) .
Is it something that can be implemented easily in the current flow ? Will be happy to help out if its something that won't need a lot of refactoring.
Wow, thanks for the feedback!
Just to clarify If I got it: you have a table with some Decimal columns that have a high precision (say, 10):
:) select toFloat32(rand() / 10000) x, toDecimal64(x, 10) y;
┌─────────x─┬────────────────y─┐
│ 38153.816 │ 38153.8151694336 │
└───────────┴──────────────────
and with something like set_printoptions(precision=4), you expect to see this:
┌─────────x─┬──────────y─┐
│ 38153.816 │ 8153.8152 │
└───────────┴────────────┘
right?
I'd just use round(y, 4), is it too much of a PITA for you?
It's just.. implementing such thing on the client's side requires the client to parse of the whole response and it's gotta take into account the format, column types and whatnot
The roundoff thing is what I have been doing using intDiv, it's just that for when checking the subqueries of large joins and select * it becomes very cumbersome
Will doing a simple regex based substitution on the response data before printing to console work ?
Sample regex I tested for precision of 2 decimals, that should work in most cases i can think of : https://regex101.com/r/I4F7Hc/6/
It will replace any strings columns in that format too, but I guess it can be specified as warning for enabling this setting.
otherwise, yes its seems too much to work to parse the entire output for just a luxury feature.