# Buggy code
def register_predictors(self, model_data_arr):
    for model_meta in model_data_arr:
        name = model_meta["name"]
        stats = model_meta["data_analysis"]
        if "columns_to_ignore" in stats:
            del stats["columns_to_ignore"]
        columns_sql = ",".join(self._to_clickhouse_table(stats, model_meta["predict"]))
        columns_sql += ",`select_data_query` Nullable(String)"
        columns_sql += ",`external_datasource` Nullable(String)"
        for col in model_meta["predict"]:
            columns_sql += f",`{col}_confidence` Nullable(Float64)"
            if model_meta["data_analysis"][col]["typing"]["data_type"] == "Numeric":
                columns_sql += f",`{col}_min` Nullable(Float64)"
                columns_sql += f",`{col}_max` Nullable(Float64)"
            columns_sql += f",`{col}_explain` Nullable(String)"

        msqyl_conn = (
            self.config["api"]["mysql"]["host"]
            + ":"
            + str(self.config["api"]["mysql"]["port"])
        )
        msqyl_pass = self.config["api"]["mysql"]["password"]
        msqyl_user = self._get_mysql_user()

        q = f"""
                    CREATE TABLE mindsdb.{name}
                    ({columns_sql}
                    ) ENGINE=MySQL('{msqyl_conn}', 'mindsdb', {name}, '{msqyl_user}', '{msqyl_pass}')
            """
        self._query(q)


# Traceback (Exception)
Using configuration file: config.json
Traceback (most recent call last):
File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/zoran/MyProjects/mindsdb/mindsdb/__main__.py", line 61, in <module>
dbw.register_predictors(model_data_arr)
File "/home/zoran/MyProjects/mindsdb/mindsdb/interfaces/database/database.py", line 41, in register_predictors
for integration in it: integration.register_predictors(model_data_arr)
File "/home/zoran/MyProjects/mindsdb/mindsdb/integrations/clickhouse/clickhouse.py", line 115, in register_predictors
self._query(q)
File "/home/zoran/MyProjects/mindsdb/mindsdb/integrations/clickhouse/clickhouse.py", line 58, in _query
raise Exception(f'Error: {response.content}\nQuery:{query}')
Exception: Error: b'Code: 62, e.displayText() = DB::Exception: Syntax error: failed at position 51 (line 2, col 50): -class\n                    ( `Number of times pregnant` Nullable(String) , `Plasma glucose concentration` Nullable(Int64) , `Diastolic blood pressure` Nullable(. Expected one of: storage definition, ENGINE, AS, UUID, OpeningRoundBracket, ON, Dot, token (version 20.5.2.7 (official build))\n'
Query:
CREATE TABLE mindsdb.diabetes-class
( `Number of times pregnant` Nullable(String) , `Plasma glucose concentration` Nullable(Int64) , `Diastolic blood pressure` Nullable(Int64) , `Triceps skin fold thickness` Nullable(Int64) , `2-Hour serum insulin` Nullable(Int64) , `Body mass index` Nullable(Float64) , `Diabetes pedigree function` Nullable(Float64) , `Age` Nullable(Int64) , `Class` Nullable(String) , `Class_original` Nullable(String) ,`select_data_query` Nullable(String),`Class_confidence` Nullable(Float64),`Class_explain` Nullable(String)
) ENGINE=MySQL('127.0.0.1:47335', 'mindsdb', 'diabetes-class_clickhouse', 'root', 'somepass')

# Fixed code
def register_predictors(self, model_data_arr):
    for model_meta in model_data_arr:
        name = self._escape_table_name(model_meta["name"])
        stats = model_meta["data_analysis"]
        if "columns_to_ignore" in stats:
            del stats["columns_to_ignore"]
        columns_sql = ",".join(self._to_clickhouse_table(stats, model_meta["predict"]))
        columns_sql += ",`select_data_query` Nullable(String)"
        columns_sql += ",`external_datasource` Nullable(String)"
        for col in model_meta["predict"]:
            columns_sql += f",`{col}_confidence` Nullable(Float64)"
            if model_meta["data_analysis"][col]["typing"]["data_type"] == "Numeric":
                columns_sql += f",`{col}_min` Nullable(Float64)"
                columns_sql += f",`{col}_max` Nullable(Float64)"
            columns_sql += f",`{col}_explain` Nullable(String)"

        msqyl_conn = (
            self.config["api"]["mysql"]["host"]
            + ":"
            + str(self.config["api"]["mysql"]["port"])
        )
        msqyl_pass = self.config["api"]["mysql"]["password"]
        msqyl_user = self._get_mysql_user()

        q = f"""
                    CREATE TABLE mindsdb.{name}
                    ({columns_sql}
                    ) ENGINE=MySQL('{msqyl_conn}', 'mindsdb', {name}, '{msqyl_user}', '{msqyl_pass}')
            """
        self._query(q)