v.23.4Improvement

Make Schema Inference Work for CREATE AS SELECT

Make Schema inference works for CREATE AS SELECT. Closes #47599. #48679 (flynn).
Enable schema inference for CREATE TABLE AS SELECT statements in ClickHouse.

Why it matters

This feature addresses the lack of automatic schema inference when creating tables using the CREATE TABLE AS SELECT syntax. It simplifies table creation by automatically deriving the schema from the SELECT query, eliminating the need for manual column specification and reducing errors.

How to use it

Use the standard CREATE TABLE <table_name> AS SELECT syntax to create a new table. ClickHouse will automatically infer the schema from the SELECT statement without requiring explicit column definitions.