CREATE TABLE ... **EMPTY** AS SELECT

**Use case**

Create a table with the same structure as SELECT query returns but don't fill it.

**Describe alternatives you've considered**

CREATE TABLE ... AS DESCRIBE (SELECT ...)

\- more consistent but also more clunky.
}
    
    TableProperties properties = getTablePropertiesAndNormalizeCreateQuery(create);
    
    if (create.select && create.is_materialized_view && create.to_table_id)
    {
        if (StoragePtr to_table = DatabaseCatalog::instance().tryGetTable(
            {create.to_table_id.database_name, create.to_table_id.table_name, create.to_table_id.uuid},
            getContext()
        ))
        {
            Block input_block = InterpreterSelectWithUnionQuery(
                create.select->clone(), getContext(), SelectQueryOptions().analyze()).getSampleBlock();
            Block output_block = to_table->getInMemoryMetadataPtr()->getSampleBlock();
            ColumnsWithTypeAndName input_columns;
            ColumnsWithTypeAndName output_columns;
            for (const auto & input_column : input_block)
            {
                if (const auto * output_column = output_block.findByName(input_column.name))
                {
                    input_columns.push_back(input_column.cloneEmpty());
                    output_columns.push_back(output_column->cloneEmpty());
                }
            }
            ActionsDAG::makeConvertingActions(
                input_columns,
                output_columns,
                ActionsDAG::MatchColumnsMode::Position
            );
        }