Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-2882

Unsupported MariaDB syntax for generated columns

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.4.0.Final
    • 1.4.0.CR1
    • mysql-connector
    • None
    • False
    • False
    • Undefined
    • Hide

      Start MySqlConnector to read changes from a database having at least one table with generated column. Example:

          CREATE TABLE `some_stats` (
            `id` int NOT NULL AUTO_INCREMENT,
            `ip` varchar(40) NULL,
            `token` varchar(4096) NOT NULL,
            `token_and_ip_hash` char(64) AS (SHA2(CONCAT(`token`, COALESCE(`ip`, "")), 256)) PERSISTENT,
            `last_used_at` datetime NULL,
            `calls` int unsigned DEFAULT 0,
            `errors` int unsigned DEFAULT 0,
            PRIMARY KEY (`id`),
            UNIQUE KEY `token_and_ip_hash` (`token_and_ip_hash`)
          ) ENGINE=InnoDB;
      

       

      Show
      Start MySqlConnector to read changes from a database having at least one table with generated column. Example: CREATE TABLE `some_stats` ( `id` int NOT NULL AUTO_INCREMENT, `ip` varchar(40) NULL, `token` varchar(4096) NOT NULL, `token_and_ip_hash` char (64) AS (SHA2(CONCAT(`token`, COALESCE(`ip`, "")), 256)) PERSISTENT, `last_used_at` datetime NULL, `calls` int unsigned DEFAULT 0, `errors` int unsigned DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `token_and_ip_hash` (`token_and_ip_hash`) ) ENGINE=InnoDB;  

      During initial snapshot, the following error happens:

      connect_1    | 2021-01-01 22:36:00,036 ERROR  ||  WorkerSourceTask{id=my-connector-0} Task threw an uncaught and unrecoverable exception   [org.apache.kafka.connect.runtime.WorkerTask]connect_1    | 2021-01-01 22:36:00,036 ERROR  ||  WorkerSourceTask{id=Centra-connector-0} Task threw an uncaught and unrecoverable exception   [org.apache.kafka.connect.runtime.WorkerTask]connect_1    | org.apache.kafka.connect.errors.ConnectException: no viable alternative at input 'CREATE TABLE `some_stats` (\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `ip` varchar(40) DEFAULT NULL,\n  `token` varchar(4096) NOT NULL,\n  `token_and_ip_hash` char(64) AS (SHA2(CONCAT(`token`, COALESCE(`ip`, "")), 256)) PERSISTENT'connect_1    | at io.debezium.connector.mysql.AbstractReader.wrap(AbstractReader.java:241)connect_1    | at io.debezium.connector.mysql.AbstractReader.failed(AbstractReader.java:218)connect_1    | at io.debezium.connector.mysql.SnapshotReader.execute(SnapshotReader.java:848)connect_1    | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)connect_1    | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)connect_1    | at java.base/java.lang.Thread.run(Thread.java:834)connect_1    | Caused by: io.debezium.text.ParsingException: no viable alternative at input 'CREATE TABLE `some_stats` (\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `ip` varchar(40) DEFAULT NULL,\n  `token` varchar(4096) NOT NULL,\n  `token_and_ip_hash` char(64) AS (SHA2(CONCAT(`token`, COALESCE(`ip`, "")), 256)) PERSISTENT'connect_1    | at io.debezium.antlr.ParsingErrorListener.syntaxError(ParsingErrorListener.java:40)connect_1    | at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)connect_1    | at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:544)connect_1    | at org.antlr.v4.runtime.DefaultErrorStrategy.reportNoViableAlternative(DefaultErrorStrategy.java:310)connect_1    | at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:136)connect_1    | at io.debezium.ddl.parser.mysql.generated.MySqlParser.sqlStatements(MySqlParser.java:1157)connect_1    | at io.debezium.ddl.parser.mysql.generated.MySqlParser.root(MySqlParser.java:885)connect_1    | at io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:68)connect_1    | at io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:41)connect_1    | at io.debezium.antlr.AntlrDdlParser.parse(AntlrDdlParser.java:80)connect_1    | at io.debezium.connector.mysql.MySqlSchema.applyDdl(MySqlSchema.java:326)connect_1    | at io.debezium.connector.mysql.SnapshotReader.lambda$readTableSchema$17(SnapshotReader.java:881)connect_1    | at io.debezium.jdbc.JdbcConnection.query(JdbcConnection.java:556)connect_1    | at io.debezium.jdbc.JdbcConnection.query(JdbcConnection.java:497)connect_1    | at io.debezium.connector.mysql.SnapshotReader.readTableSchema(SnapshotReader.java:879)connect_1    | at io.debezium.connector.mysql.SnapshotReader.execute(SnapshotReader.java:541)
      

      Apparently, generated column syntax is not supported by Debezium grammar.

      MySQL docs
      MariaDB docs

       

              jpechane Jiri Pechanec
              jacek.symonowicz Jacek Symonowicz
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: