Skip to content

clickhouse-client does not properly handle the case when both immediate data and stdin are present. #36100

Closed

Description

@alexey-milovidov

Describe the issue

CREATE TABLE test (a String, b String) ENGINE = Memory

This command properly displaying the error about mismatching number of columns:

echo "(1, 2, 3)" | clickhouse-client --query "
                    INSERT INTO test
                    SELECT 'Hello', 'World'
                    FROM input('x UInt32')
                    FORMAT Values"

This command also works properly, displaying the error:

echo "(1, 2, 3)" | clickhouse-client --query "
                    INSERT INTO test
                    SELECT 'Hello', 'World'
                    FROM input('x UInt32')
                    FORMAT Values
"

But this displays nothing:

echo "(1, 2, 3)" | clickhouse-client --query "
                    INSERT INTO test
                    SELECT 'Hello', 'World'
                    FROM input('x UInt32')
                    FORMAT Values
 "

It happens, because the last command has immediate data.

According to the specs, if FORMAT present in INSERT query, the parser should skip all whitespace characters after FORMAT before first newline (including the first newline) or before first non-whitespace character, and treat all the remaining content as data stream.

So, in this example, the query contains immediate data, represented by single whitespace character: .
And this embedded data is correctly parsed as empty dataset in Values format.

But the problem is that this command also contains data from stdin.
This behaviour (silently ignore stdin) is not what user expects.

How to solve

Concatenate immediate data and stdin, similarly to how it is done in HTTP interface.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions