**How to reproduce**

clickhouse-local:
```
CREATE TABLE f (`s` String) ENGINE = File(TSV, '/dev/null');
CREATE VIEW v AS SELECT * FROM f;
SELECT '', NULL FROM merge('', '\0');
```

{
    ASTTableExpression * table_expression = getFirstTableExpression(outer_query);
    if (!table_expression->database_and_table_name)
    {
        
        if (table_expression->table_function)
        {
            auto table_function_name = table_expression->table_function->as<ASTFunction>()->name;
            if ((table_function_name == "view") || (table_function_name == "viewIfPermitted"))
                table_expression->database_and_table_name = std::make_shared<ASTTableIdentifier>("__view");
        }
        if (!table_expression->database_and_table_name)
            throw Exception("Logical error: incorrect table expression", ErrorCodes::LOGICAL_ERROR);
    }
    DatabaseAndTableWithAlias db_table(table_expression->database_and_table_name);
    String alias = db_table.alias.empty() ? db_table.table : db_table.alias;
    view_name = table_expression->database_and_table_name;
    table_expression->database_and_table_name = {};
    table_expression->subquery = std::make_shared<ASTSubquery>();
    table_expression->subquery->children.push_back(view_query);
    table_expression->subquery->setAlias(alias);
    for (auto & child : table_expression->children)
        if (child.get() == view_name.get())
            child = view_query;
}
ASTPtr StorageView::restoreViewName(ASTSelectQuery & select_query, const ASTPtr & view_name)