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

Debezium goes into failed state with error `no viable alternative at input`

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • 0.9.5.Final
    • mysql-connector
    • None
    • Hide

      These are the statements that were executed:

      ALTER DATABASE CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
      
      DELIMITER //
      
      CREATE FUNCTION idToBinary(_uuid VARCHAR(36))
        RETURNS BINARY(16)
      LANGUAGE SQL DETERMINISTIC CONTAINS SQL SQL SECURITY INVOKER
      
        BEGIN
      
          IF _uuid IS NULL
          THEN RETURN NULL;
          END IF;
      
          -- sparkFlakeId To Binary
          IF LENGTH(_uuid) = 26 THEN
            RETURN
            UNHEX(CONCAT(
                      '000000000',
                      SUBSTR(_uuid, 1, 1),
                      SUBSTR(_uuid, 3, 11),
                      SUBSTR(_uuid, 15, 3),
                      SUBSTR(_uuid, 19, 8)));
          END IF;
      
          -- UUID to binary
          RETURN
          UNHEX(CONCAT(
                    SUBSTR(_uuid, 15, 4),
                    SUBSTR(_uuid, 10, 4),
                    SUBSTR(_uuid, 1, 8),
                    SUBSTR(_uuid, 20, 4),
                    SUBSTR(_uuid, 25)));
      
        END //
      
      DELIMITER ;
      
      DELIMITER //
      CREATE FUNCTION binaryToId(_bin BINARY(16))
        RETURNS VARCHAR(36)
      LANGUAGE SQL DETERMINISTIC CONTAINS SQL SQL SECURITY INVOKER
      
        BEGIN
      
          IF _bin IS NULL
          THEN RETURN NULL;
          END IF;
      
          -- Binary to SparkflakeId
          IF SUBSTR(HEX(_bin), 1, 9) = '000000000' THEN
            RETURN
            LCASE(CONCAT_WS('-',
                            SUBSTR(HEX(_bin), 10, 1),
                            SUBSTR(HEX(_bin), 11, 11),
                            SUBSTR(HEX(_bin), 22, 3),
                            SUBSTR(HEX(_bin), 25, 8)
                  ));
          END IF;
      
          -- Binary to UUID
          RETURN
          LCASE(CONCAT_WS('-',
                          HEX(SUBSTR(_bin, 5, 4)),
                          HEX(SUBSTR(_bin, 3, 2)),
                          HEX(SUBSTR(_bin, 1, 2)),
                          HEX(SUBSTR(_bin, 9, 2)),
                          HEX(SUBSTR(_bin, 11))
                ));
        END //
      DELIMITER ;
      
      
      Show
      These are the statements that were executed: ALTER DATABASE CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci; DELIMITER // CREATE FUNCTION idToBinary(_uuid VARCHAR (36)) RETURNS BINARY (16) LANGUAGE SQL DETERMINISTIC CONTAINS SQL SQL SECURITY INVOKER BEGIN IF _uuid IS NULL THEN RETURN NULL ; END IF ; -- sparkFlakeId To Binary IF LENGTH (_uuid) = 26 THEN RETURN UNHEX(CONCAT( '000000000' , SUBSTR(_uuid, 1, 1), SUBSTR(_uuid, 3, 11), SUBSTR(_uuid, 15, 3), SUBSTR(_uuid, 19, 8))); END IF ; -- UUID to binary RETURN UNHEX(CONCAT( SUBSTR(_uuid, 15, 4), SUBSTR(_uuid, 10, 4), SUBSTR(_uuid, 1, 8), SUBSTR(_uuid, 20, 4), SUBSTR(_uuid, 25))); END // DELIMITER ; DELIMITER // CREATE FUNCTION binaryToId(_bin BINARY (16)) RETURNS VARCHAR (36) LANGUAGE SQL DETERMINISTIC CONTAINS SQL SQL SECURITY INVOKER BEGIN IF _bin IS NULL THEN RETURN NULL ; END IF ; -- Binary to SparkflakeId IF SUBSTR(HEX(_bin), 1, 9) = '000000000' THEN RETURN LCASE(CONCAT_WS( '-' , SUBSTR(HEX(_bin), 10, 1), SUBSTR(HEX(_bin), 11, 11), SUBSTR(HEX(_bin), 22, 3), SUBSTR(HEX(_bin), 25, 8) )); END IF ; -- Binary to UUID RETURN LCASE(CONCAT_WS( '-' , HEX(SUBSTR(_bin, 5, 4)), HEX(SUBSTR(_bin, 3, 2)), HEX(SUBSTR(_bin, 1, 2)), HEX(SUBSTR(_bin, 9, 2)), HEX(SUBSTR(_bin, 11)) )); END // DELIMITER ;

      The connector goes into FAILED state with the following error:

      org.apache.kafka.connect.errors.ConnectException: no viable alternative at input 'CREATE DEFINER=`root`@`%` FUNCTION `binaryToId`(_bin BINARY(16)) RETURNS varchar(36) CHARSET utf8mb4 COLLATE'\n\tat io.debezium.connector.mysql.AbstractReader.wrap(AbstractReader.java:230)\n\tat io.debezium.connector.mysql.AbstractReader.failed(AbstractReader.java:208)\n\tat io.debezium.connector.mysql.BinlogReader.handleEvent(BinlogReader.java:508)\n\tat com.github.shyiko.mysql.binlog.BinaryLogClient.notifyEventListeners(BinaryLogClient.java:1095)\n\tat com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:943)\n\tat com.github.shyiko.mysql.binlog.BinaryLogClient.connect(BinaryLogClient.java:580)\n\tat com.github.shyiko.mysql.binlog.BinaryLogClient$7.run(BinaryLogClient.java:825)\n\tat java.lang.Thread.run(Thread.java:748)\nCaused by: io.debezium.text.ParsingException: no viable alternative at input 'CREATE DEFINER=`root`@`%` FUNCTION `binaryToId`(_bin BINARY(16)) RETURNS varchar(36) CHARSET utf8mb4 COLLATE'\n\tat io.debezium.antlr.ParsingErrorListener.syntaxError(ParsingErrorListener.java:40)\n\tat org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)\n\tat org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:544)\n\tat org.antlr.v4.runtime.DefaultErrorStrategy.reportNoViableAlternative(DefaultErrorStrategy.java:282)\n\tat org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:121)\n\tat io.debezium.ddl.parser.mysql.generated.MySqlParser.sqlStatements(MySqlParser.java:1078)\n\tat io.debezium.ddl.parser.mysql.generated.MySqlParser.root(MySqlParser.java:812)\n\tat io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:68)\n\tat io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:41)\n\tat io.debezium.antlr.AntlrDdlParser.parse(AntlrDdlParser.java:80)\n\tat io.debezium.connector.mysql.MySqlSchema.applyDdl(MySqlSchema.java:307)\n\tat io.debezium.connector.mysql.BinlogReader.handleQueryEvent(BinlogReader.java:694)\n\tat io.debezium.connector.mysql.BinlogReader.handleEvent(BinlogReader.java:492)\n\t... 5 more\nCaused by: org.antlr.v4.runtime.NoViableAltException\n\tat org.antlr.v4.runtime.atn.ParserATNSimulator.noViableAlt(ParserATNSimulator.java:2023)\n\tat org.antlr.v4.runtime.atn.ParserATNSimulator.execATN(ParserATNSimulator.java:467)\n\tat org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict(ParserATNSimulator.java:393)\n\tat io.debezium.ddl.parser.mysql.generated.MySqlParser.sqlStatements(MySqlParser.java:886)
      

      Kind regards,
      Bart

              jpechane Jiri Pechanec
              bdeneuter@gmail.com bart de neuter (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: