v.21.4Improvements

Improve clickhouse-format error handling for queries

Improve clickhouse-format to not throw exception when there are extra spaces or comment after the last query, and throw exception early with readable message when format ASTInsertQuery with data . #21311 (flynn).
Improved clickhouse-format tool to handle extra spaces or comments after the last query without throwing exceptions and enhanced error reporting for formatting ASTInsertQuery with data.

Why it matters

This feature addresses robustness and usability issues in the clickhouse-format tool by preventing unexpected exceptions caused by trailing spaces or comments, and by providing clearer, earlier error messages when attempting to format insert queries containing data. This improves the developer experience by making error diagnostics easier and avoiding disruptions during formatting.

How to use it

Use the clickhouse-format tool as usual. The tool now automatically tolerates extra spaces or comments after the last query without raising errors, and if you format an ASTInsertQuery that includes data, the tool will produce a readable error message early in the process.