**Describe what's wrong**

An error occures when we are selecting data from a table with Kafka engine

**How to reproduce**

* Which ClickHouse server version to use
Clickhouse 21.9.3.30
* `CREATE TABLE` statements for all tables involved

CREATE TABLE kafka_fundevwh.QueueCheck
(
    `message` String
)
ENGINE = Kafka
SETTINGS kafka_broker_list = 'brokers', kafka_topic_list = 'topic', kafka_group_name = 'group', kafka_format = 'JSONAsString', kafka_num_consumers = 1, kafka_max_block_size = 1, kafka_flush_interval_ms = 60000

* Data sample (message)

{
  "timestamp": "2021-09-20 14:29:14",
  "action": "bet"
}

* Queries to run that lead to unexpected result

SELECT if(action = 'bonus', sport_amount, 0) * 100
FROM
(
    SELECT
        JSONExtract(message, 'action', 'String') AS action,
        JSONExtract(message, 'sport_amount', 'Float64') AS sport_amount
    FROM kafka_fundevwh.QueueCheck
)

**Expected behavior**

Data selection without any errors

**Error message and/or stacktrace**

2021.09.27 08:18:02.867302 [ 29442 ] {6132ab14-0734-4cdb-9f86-fd16244ae6b5} <Error> TCPHandler: Code: 48. DB::Exception: Column Function is not a contiguous block of memory: while executing 'FUNCTION [compiled] multiply(if(UInt8, Float64,
 0 : UInt8), 100 : UInt8)(equals(action, 'bonus') :: 2, sport_amount :: 6) -> multiply(if(equals(action, 'bonus'), sport_amount, 0), 100) Float64 : 5'. (NOT_IMPLEMENTED), Stack trace (when copying this message, always include the lines be
low):

0. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0x936713a in /usr/bin/clickhouse
1. DB::IColumn::getRawData() const @ 0x105040e4 in /usr/bin/clickhouse
2. DB::getColumnData(DB::IColumn const*) @ 0x10f271e0 in /usr/bin/clickhouse
3. DB::LLVMExecutableFunction::executeImpl(std::__1::vector<DB::ColumnWithTypeAndName, std::__1::allocator<DB::ColumnWithTypeAndName> > const&, std::__1::shared_ptr<DB::IDataType const> const&, unsigned long) const @ 0x10835b07 in /usr/bi
n/clickhouse
4. DB::IExecutableFunction::executeWithoutLowCardinalityColumns(std::__1::vector<DB::ColumnWithTypeAndName, std::__1::allocator<DB::ColumnWithTypeAndName> > const&, std::__1::shared_ptr<DB::IDataType const> const&, unsigned long, bool) co
nst @ 0x1019359e in /usr/bin/clickhouse
5. DB::IExecutableFunction::execute(std::__1::vector<DB::ColumnWithTypeAndName, std::__1::allocator<DB::ColumnWithTypeAndName> > const&, std::__1::shared_ptr<DB::IDataType const> const&, unsigned long, bool) const @ 0x10193bb2 in /usr/bin
/clickhouse
6. DB::ExpressionActions::execute(DB::Block&, unsigned long&, bool) const @ 0x1081dc72 in /usr/bin/clickhouse
7. DB::ExpressionTransform::transform(DB::Chunk&) @ 0x1197905c in /usr/bin/clickhouse
8. DB::ISimpleTransform::transform(DB::Chunk&, DB::Chunk&) @ 0xea01510 in /usr/bin/clickhouse
9. DB::ISimpleTransform::work() @ 0x117e31a7 in /usr/bin/clickhouse
10. ? @ 0x118211fd in /usr/bin/clickhouse
11. DB::PipelineExecutor::executeStepImpl(unsigned long, unsigned long, std::__1::atomic<bool>*) @ 0x1181d9d1 in /usr/bin/clickhouse
12. DB::PipelineExecutor::executeImpl(unsigned long) @ 0x1181ba2f in /usr/bin/clickhouse
13. DB::PipelineExecutor::execute(unsigned long) @ 0x1181b7f9 in /usr/bin/clickhouse
14. ? @ 0x1182877f in /usr/bin/clickhouse
15. ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0x93a815f in /usr/bin/clickhouse
16. ? @ 0x93aba43 in /usr/bin/clickhouse
17. start_thread @ 0x7fa3 in /lib/x86_64-linux-gnu/libpthread-2.28.so
18. clone @ 0xf94cf in /lib/x86_64-linux-gnu/libc-2.28.so

continue;
        stack.emplace(Frame{.node = &node});
        while (!stack.empty())
        {
            auto & current_frame = stack.top();
            auto & current_node = current_frame.node;
            while (current_frame.next_child_to_visit < current_node->children.size())
            {
                const auto & child = node.children[current_frame.next_child_to_visit];
                if (visited_nodes.contains(child))
                {
                    ++current_frame.next_child_to_visit;
                    continue;
                }
                stack.emplace(Frame{.node=child});
                break;
            }
            bool all_children_visited = current_frame.next_child_to_visit == current_node->children.size();
            if (!all_children_visited)
                continue;
            auto & current_node_data = node_to_data[current_node];
            if (current_node_data.is_compilable_in_isolation)
            {
                for (const auto * child : current_node->children)
                {
                    auto & child_data = node_to_data[child];
                    if (child_data.is_compilable_in_isolation)
                    {
                        current_node_data.compilable_children_size += child_data.compilable_children_size;
                        current_node_data.compilable_children_size += 1;