When I used ClickHouse's MaterializeMySQL feature to synchronize data from MySQL to ClickHouse, I had some problems. The Click House version I'm using is 20.10.3.30, and the MySQL version I'm using is 5.7.28-log.

The SQL statement I executed is as follows:
> SET allow_experimental_database_materialize_mysql = 1;
drop database if exists ck_test;
CREATE DATABASE if not exists ck_test ENGINE = MaterializeMySQL('x.x.x.x:3306', 'test', 'user', 'test');


After I executed the SQL statement, I saw the following information from the error log /var/log/clickhouse-server/clickhouse-server.err. Log:

> 2020.11.10 20:27:39.611578 [ 33057 ] {} <Error> MaterializeMySQLSyncThread: Code: 20, e.displayText() = DB::Exception: mysqlxx::UseQueryResult contains 4 columns while 2 expected, Stack trace (when copying this message, always include the lines below):

> 0. DB::MySQLBlockInputStream::MySQLBlockInputStream(mysqlxx::Pool::Entry const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::Block const&, unsigned long, bool) @ 0xe587457 in /usr/bin/clickhouse

> 1. DB::MaterializeMetadata::MaterializeMetadata(mysqlxx::Pool::Entry&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) @ 0xdb1cbf3 in /usr/bin/clickhouse

> 2. DB::MaterializeMySQLSyncThread::prepareSynchronized(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) @ 0xdaf8bf1 in /usr/bin/clickhouse

> 3. DB::MaterializeMySQLSyncThread::synchronization(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) @ 0xdaf836a in /usr/bin/clickhouse

> 4. ? @ 0xdb1480d in /usr/bin/clickhouse

> 5. ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0x7b8963d in /usr/bin/clickhouse

> 6. ? @ 0x7b8d153 in /usr/bin/clickhouse

> 7. start_thread @ 0x7dd5 in /usr/lib64/libpthread-2.17.so

> 8. __clone @ 0xfdead in /usr/lib64/libc-2.17.so

>  (version 20.10.3.30 (official build))


Does anybody have a problem like this?
{
            for (size_t index = 0; index < rows_data.size(); ++index)
            {
                const Tuple & row_data = DB::get<const Tuple &>(rows_data[index]);
                const Field & value = row_data[column_index];
                if (write_data_to_null_map(value, index))
                    casted_column->insertValue(static_cast<decltype(to_type)>(value.template get<decltype(from_type)>()));
            }
        };
        if (ColumnInt8 * casted_int8_column = typeid_cast<ColumnInt8 *>(&column_to))
            write_data_to_column(casted_int8_column, UInt64(), Int8());
        else if (ColumnInt16 * casted_int16_column = typeid_cast<ColumnInt16 *>(&column_to))
            write_data_to_column(casted_int16_column, UInt64(), Int16());
        else if (ColumnInt64 * casted_int64_column = typeid_cast<ColumnInt64 *>(&column_to))
            write_data_to_column(casted_int64_column, UInt64(), Int64());
        else if (ColumnUInt8 * casted_uint8_column = typeid_cast<ColumnUInt8 *>(&column_to))
            write_data_to_column(casted_uint8_column, UInt64(), UInt8());
        else if (ColumnUInt16 * casted_uint16_column = typeid_cast<ColumnUInt16 *>(&column_to))
            write_data_to_column(casted_uint16_column, UInt64(), UInt16());
        else if (ColumnUInt32 * casted_uint32_column = typeid_cast<ColumnUInt32 *>(&column_to))
            write_data_to_column(casted_uint32_column, UInt64(), UInt32());
        else if (ColumnUInt64 * casted_uint64_column = typeid_cast<ColumnUInt64 *>(&column_to))
            write_data_to_column(casted_uint64_column, UInt64(), UInt64());
        else if (ColumnFloat32 * casted_float32_column = typeid_cast<ColumnFloat32 *>(&column_to))
            write_data_to_column(casted_float32_column, Float64(), Float32());
        else if (ColumnFloat64 * casted_float64_column = typeid_cast<ColumnFloat64 *>(&column_to))
            write_data_to_column(casted_float64_column, Float64(), Float64());
        else if (ColumnDecimal<Decimal32> * casted_decimal_32_column = typeid_cast<ColumnDecimal<Decimal32> *>(&column_to))
            write_data_to_column(casted_decimal_32_column, Decimal32(), Decimal32());
        else if (ColumnDecimal<Decimal64> * casted_decimal_64_column = typeid_cast<ColumnDecimal<Decimal64> *>(&column_to))