v.21.9Improvement

Allow Multiple Reads from Regular Files in ClickHouse Local

If file descriptor in File table is regular file - allow to read multiple times from it. It allows clickhouse-local to read multiple times from stdin (with multiple SELECT queries or subqueries) if stdin is a regular file like clickhouse-local --query "SELECT * FROM table UNION ALL SELECT * FROM table" ... < file. This closes #11124. Co-authored with (alexey-milovidov). #25960 (BoloniniD).
Allows clickhouse-local to read multiple times from stdin if stdin is a regular file by enabling multiple reads from the same file descriptor in the File table.

Why it matters

This feature resolves the issue where clickhouse-local could not execute multiple SELECT queries or subqueries reading from stdin when it was a regular file. It enables scenarios like running multiple queries with input redirected from a file, improving usability and flexibility for batch processing and complex query executions using stdin.

How to use it

Simply redirect a regular file as stdin to clickhouse-local with multiple SELECT queries or subqueries. For example:

clickhouse-local --query "SELECT * FROM table UNION ALL SELECT * FROM table" < file

This allows the input file to be read multiple times within the same command session.