v.24.5Improvement

Allow Positional Arguments for Queries in ClickHouse Local Command-Line Tools

Allow using clickhouse-local and its shortcuts clickhouse and ch with a query or queries file as a positional argument. Examples: ch "SELECT 1", ch --param_test Hello "SELECT {test:String}", ch query.sql. This closes #62361. #63081 (Alexey Milovidov).
Allow using clickhouse-local and its shortcuts clickhouse and ch with a query or queries file as a positional argument.

Why it matters

This feature simplifies running queries locally by enabling users to provide the SQL query or a file containing queries directly as positional arguments, removing the need for additional flags or input redirection. It improves usability and streamlines command execution for local testing and development.

How to use it

You can run queries by passing the SQL directly as a positional argument, for example:

ch "SELECT 1"
ch --param_test Hello "SELECT {test:String}"
ch query.sql

Here, ch is a shortcut for clickhouse-local. Queries can be provided inline or from a file without extra flags.