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

Error and connector stops when DDL contains lateral

XMLWordPrintable

    • False
    • False
    • Hide

      Execute the following mysql statement:

      CREATE OR REPLACE ALGORITHM=MERGE DEFINER=`dbuser`@`%` SQL SECURITY DEFINER VIEW `invoice_payments_stats` AS select `i`.`id` AS `id`,if(((`i`.`status` not in ('draft','void','paid')) and (`ps`.`partial_payments_amount` > 0) and (`ps`.`partial_payments_amount` < `i`.`total`)),`ps`.`partial_payments_amount`,NULL) AS `partial_payments_amount`,if(((`i`.`status` not in ('draft','void','paid')) and (`ps`.`partial_payments_amount` > 0) and (`ps`.`partial_payments_amount` < `i`.`total`)),(`i`.`total` - `ps`.`partial_payments_amount`),NULL) AS `pending_payments_amount`,if((`i`.`status` = 'paid'),`ps`.`latest_payment`,NULL) AS `paid_date` from (`invoices` `i` join lateral (select max(`ip`.`date`) AS `latest_payment`,sum(`ip`.`amount`) AS `partial_payments_amount` from `invoice_payments` `ip` where (`ip`.`invoice_id` = `i`.`id`)) `ps`)

      Show
      Execute the following mysql statement: CREATE OR REPLACE ALGORITHM=MERGE DEFINER=`dbuser`@`%` SQL SECURITY DEFINER VIEW `invoice_payments_stats` AS select `i`.`id` AS `id`,if(((`i`.`status` not in ('draft','void','paid')) and (`ps`.`partial_payments_amount` > 0) and (`ps`.`partial_payments_amount` < `i`.`total`)),`ps`.`partial_payments_amount`,NULL) AS `partial_payments_amount`,if(((`i`.`status` not in ('draft','void','paid')) and (`ps`.`partial_payments_amount` > 0) and (`ps`.`partial_payments_amount` < `i`.`total`)),(`i`.`total` - `ps`.`partial_payments_amount`),NULL) AS `pending_payments_amount`,if((`i`.`status` = 'paid'),`ps`.`latest_payment`,NULL) AS `paid_date` from (`invoices` `i` join lateral (select max(`ip`.`date`) AS `latest_payment`,sum(`ip`.`amount`) AS `partial_payments_amount` from `invoice_payments` `ip` where (`ip`.`invoice_id` = `i`.`id`)) `ps`)

      When using LATERAL while creating a view a parsing exception is raised.

      This is the exception itself:

      2022-02-22 08:46:12,056 ERROR  MySQL|paymodb|binlog  Producer failure   [io.debezium.pipeline.ErrorHandler]
      io.debezium.DebeziumException: Error processing binlog event
          at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.handleEvent(MySqlStreamingChangeEventSource.java:366)
          at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.lambda$execute$25(MySqlStreamingChangeEventSource.java:855)
          at com.github.shyiko.mysql.binlog.BinaryLogClient.notifyEventListeners(BinaryLogClient.java:1125)
          at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:973)
          at com.github.shyiko.mysql.binlog.BinaryLogClient.connect(BinaryLogClient.java:599)
          at com.github.shyiko.mysql.binlog.BinaryLogClient$7.run(BinaryLogClient.java:857)
          at java.base/java.lang.Thread.run(Thread.java:829)
      Caused by: io.debezium.text.ParsingException: DDL statement couldn't be parsed. Please open a Jira issue with the statement 'CREATE OR REPLACE ALGORITHM=MERGE DEFINER=`dbuser`@`%` SQL SECURITY DEFINER VIEW `invoice_payments_stats` AS select `i`.`id` AS `id`,if(((`i`.`status` not in ('draft','void','paid')) and (`ps`.`partial_payments_amount` > 0) and (`ps`.`partial_payments_amount` < `i`.`total`)),`ps`.`partial_payments_amount`,NULL) AS `partial_payments_amount`,if(((`i`.`status` not in ('draft','void','paid')) and (`ps`.`partial_payments_amount` > 0) and (`ps`.`partial_payments_amount` < `i`.`total`)),(`i`.`total` - `ps`.`partial_payments_amount`),NULL) AS `pending_payments_amount`,if((`i`.`status` = 'paid'),`ps`.`latest_payment`,NULL) AS `paid_date` from (`invoices` `i` join lateral (select max(`ip`.`date`) AS `latest_payment`,sum(`ip`.`amount`) AS `partial_payments_amount` from `invoice_payments` `ip` where (`ip`.`invoice_id` = `i`.`id`)) `ps`)'
      no viable alternative at input 'CREATE OR REPLACE ALGORITHM=MERGE DEFINER=`dbuser`@`%` SQL SECURITY DEFINER VIEW `invoice_payments_stats` AS select `i`.`id` AS `id`,if(((`i`.`status` not in ('draft','void','paid')) and (`ps`.`partial_payments_amount` > 0) and (`ps`.`partial_payments_amount` < `i`.`total`)),`ps`.`partial_payments_amount`,NULL) AS `partial_payments_amount`,if(((`i`.`status` not in ('draft','void','paid')) and (`ps`.`partial_payments_amount` > 0) and (`ps`.`partial_payments_amount` < `i`.`total`)),(`i`.`total` - `ps`.`partial_payments_amount`),NULL) AS `pending_payments_amount`,if((`i`.`status` = 'paid'),`ps`.`latest_payment`,NULL) AS `paid_date` from (`invoices` `i` join lateral ('
          at io.debezium.antlr.ParsingErrorListener.syntaxError(ParsingErrorListener.java:43)
          at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)
          at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:544)
          at org.antlr.v4.runtime.DefaultErrorStrategy.reportNoViableAlternative(DefaultErrorStrategy.java:310)
          at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:136)
          at io.debezium.ddl.parser.mysql.generated.MySqlParser.sqlStatements(MySqlParser.java:1194)
          at io.debezium.ddl.parser.mysql.generated.MySqlParser.root(MySqlParser.java:922)
          at io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:72)
          at io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:45)
          at io.debezium.antlr.AntlrDdlParser.parse(AntlrDdlParser.java:82)
          at io.debezium.connector.mysql.MySqlDatabaseSchema.parseDdl(MySqlDatabaseSchema.java:216)
          at io.debezium.connector.mysql.MySqlDatabaseSchema.parseStreamingDdl(MySqlDatabaseSchema.java:202)
          at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.handleQueryEvent(MySqlStreamingChangeEventSource.java:573)
          at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.lambda$execute$14(MySqlStreamingChangeEventSource.java:827)
          at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.handleEvent(MySqlStreamingChangeEventSource.java:349)
          ... 6 more
      Caused by: org.antlr.v4.runtime.NoViableAltException
          at org.antlr.v4.runtime.atn.ParserATNSimulator.noViableAlt(ParserATNSimulator.java:2026)
          at org.antlr.v4.runtime.atn.ParserATNSimulator.execATN(ParserATNSimulator.java:467)
          at org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict(ParserATNSimulator.java:393)
          at io.debezium.ddl.parser.mysql.generated.MySqlParser.sqlStatements(MySqlParser.java:996)
          ... 15 more

            Unassigned Unassigned
            gergof Fándly Gergő (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: