Clickhouse: Cannot parse CSV with space delmiter.

Created on 30 Aug 2019  路  4Comments  路  Source: ClickHouse/ClickHouse

$ echo "1 2" | clickhouse-local -S "a int, b int" --input-format="CSV" --format_csv_delimiter=' ' -q "select * from table"
Code: 27, e.displayText() = DB::Exception: Cannot parse input: expected   before: 2\n: (at row 1)

Row 1:
Column 0,   name: a, type: Int32, parsed text: "1"
ERROR: There is no delimiter ( ). "2" found instead.

 (version 19.13.1.1)

Also, the expected before could use some quoting.

bug comp-formats usability

Most helpful comment

It can be done with CustomSeparated format:

$ echo "1 2" | clickhouse-local -S "a int, b int" --input-format=CustomSeparated --format_custom_escaping_rule=CSV --format_custom_field_delimiter=' ' -q "select * from table"
1   2

All 4 comments

BTW, we cannot support any delimiter that may happen to be parsed as part of value.
For example . is not supported as a delimiter, because we cannot determine, what 1.2 is.

But this is another issue: we support padding by spaces and skip spaces around values unconditionally* (before parsing delimiter). Better to introduce a setting... and probably turn it off automatically when delimiter is space.

* - this contradicts RFC.

It can be done with CustomSeparated format:

$ echo "1 2" | clickhouse-local -S "a int, b int" --input-format=CustomSeparated --format_custom_escaping_rule=CSV --format_custom_field_delimiter=' ' -q "select * from table"
1   2

We should add an error message about unsupported delimiters, and maybe mention CustomSeparated.
It's just so annoying when a simple thing breaks for unknown reasons with a cryptic message, and the user has no idea what's wrong and how it can be fixed.

I'm not woking on this now, so I'll remove myself from the assignees list.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jangorecki picture jangorecki  路  3Comments

vixa2012 picture vixa2012  路  3Comments

jangorecki picture jangorecki  路  3Comments

bseng picture bseng  路  3Comments

jimmykuo picture jimmykuo  路  3Comments