Table sink does not support update and delete chan...
# troubleshooting
n
Table sink does not support update and delete changes Hi! We're trying to read data from a MySQL binary log using the flink-sql-connector-mysql-cdc connector and we hit the above error. Isnt it possible to just print/stream the data without defining a sink? Does flink implement a sink by default even when I did not declare any? Any help appreciated
Copy code
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    env.setParallelism(4);
    env.enableCheckpointing(200);
    StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);

// Define the source (MySQL binary logs)
    String sourceDDL =
            "CREATE TABLE transactions_binlog (" +
                    " t_id BIGINT NOT NULL," +
                    " t_amount BIGINT," +
                    " t_customer_id BIGINT," +
                    " PRIMARY KEY (t_id) NOT ENFORCED " +
                    ") WITH (" +
                    " 'connector' = 'mysql-cdc'," +
                    " 'hostname' = 'localhost'," +
                    " 'port' = '64781'," +
                    " 'username' = 'localhost'," +
                    " 'password' = ''," +
                    " 'database-name' = 'example_db'," +
                    " 'table-name' = 'Transactions'" +
                    ")";

    tableEnv.executeSql(sourceDDL);

    // Create a data stream
    Table result = tableEnv.sqlQuery("SELECT * FROM transactions_binlog");
    DataStreamRow stream = tableEnv.toDataStream(result);
//    DataStreamRow appendOnlyStream = stream.filter(row -> row.getKind() == RowKind.INSERT);


    // Process the data stream
    appendOnlyStream.print();
y
Hi Nicholas, AFAIU Flink does not implement any sink in case you do not define one. You could create a simple sink that just prints data out to STDOUT.
n
If i don't create a sink it cannot print data ?
y
I see you're using
print()
, that will attach a sink that prints to STDOUT.
n
but its exactly when I use print() I get the error
Copy code
Exception in thread "main" org.apache.flink.table.api.TableException: Table sink '*anonymous_datastream_sink$1*' doesn't support consuming update and delete changes which is produced by node TableSourceScan(table=[[default_catalog, default_database, transactions_binlog]], fields=[t_id, t_amount, t_customer_id])
Any advice on overcoming this ?
y
How about you add your own sink that does that same?
Copy code
appendOnlyStream.addSink(new SinkFunction[String] {
      override def invoke(value: String, context: SinkFunction.Context): Unit = println(value)
    })