Skip to content

CLI interactive mode: formatting #118

Closed

Description

@hatarist

Why does PrettyCompact creates a new "table" for the aggregated/DISTINCT data if it isn't properly ordered? I'm not sure how to phrase this correctly, but here's an example:

:) SELECT DISTINCT toDate(created_at) FROM test FORMAT PrettyCompact;

┌─toDate(created_at)┐
│        2016-09-05 │
│        2016-09-03 │
│        2016-09-04 │
└───────────────────┘
┌─toDate(created_at)┐
│        2016-09-01 │
│        2016-09-02 │
└───────────────────┘
:) SELECT DISTINCT toDate(created_at) FROM test ORDER BY created_at FORMAT PrettyCompact;

┌─toDate(created_at)┐
│        2016-09-01 │
│        2016-09-02 │
│        2016-09-03 │
│        2016-09-04 │
│        2016-09-05 │
└───────────────────┘
:) SELECT DISTINCT toDate(created_at) FROM test FORMAT PrettyCompactMonoBlock;

┌─toDate(created_at)┐
│        2016-09-05 │
│        2016-09-03 │
│        2016-09-04 │
│        2016-09-01 │
│        2016-09-02 │
└───────────────────┘

Wouldn't it be better to make PrettyCompactMonoBlock the default formatter for the CLI?
If not, what are the use-cases of PrettyCompact behaving like that (with multiple tables displayed) being useful?

And by the way - is GitHub issues appropriate to ask these kind of questions or should I ask it on StackOverflow/Google Groups instead?

Thanks in advance!

Activity

  1. alexey-milovidov commented on Sep 26, 2016

    @alexey-milovidov
    Member

    In Pretty formats, to render a table, we need to know maximum widths of columns.
    To calculate them, we must buffer data for that table.
    But we don't want to buffer all data, for two reasons:

    1. We don't want to consume too much memory.
      (Really not a reason because there is limit for 10 000 rows in Pretty formats)
    2. We want to output data as soon as it is received.
      Data is received in blocks. As soon as each block is received, we render it.
      When query is "streaming" it will send result block by block.

    Several workarounds possible.
    We may not render each small block instantly, but wait for some timeout, and render it only if next block has not arrived within that timeout. I think, this is unnecessarily complex solution.

    By the way, it is possible to set default format in configuration file of clickhouse-client.
    Configuration file is searched in:

    ./clickhouse-client.xml
    ~/.clickhouse-client/config.xml
    /etc/clickhouse-client/config.xml
    

    Create it with following content:

    <config>
        <format>PrettyCompactMonoBlock</format>
    </config>
    

    And by the way - is GitHub issues appropriate to ask these kind of questions or should I ask it on StackOverflow/Google Groups instead?

    GitHub is appropriate. Stackoverflow is too.
    Maybe Google Groups are better (there is already more questions), but I am not sure.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions