Matan Perelmuter
12/26/2023, 9:12 AMTable sink '*anonymous_datastream_sink$1*' doesn't support consuming update and delete changes which is produced by node Join
Is there a way handle the join like an append-only stream instead of dynamic table?
(I saw I can move to changelog instead of datastream, but it gets really confusing with the watermarks, and cumbersome to write)
public class Main {
public static class myPojo {
public String id;
public myPojo() {
// Empty ctor
}
public myPojo(String id) {
this.id = id;
}
}
public static class myPojoExtra extends myPojo {
public String extra_data;
public myPojoExtra() {
// Empty ctor
}
}
public static void createStaticTable(StreamTableEnvironment tEnv) {
// Define a table schema
Schema schema = Schema.newBuilder()
.column("id", DataTypes.STRING())
.column("extra_data", DataTypes.STRING())
.build();
// Create a table
tEnv.createTable("StaticTable",
TableDescriptor.forConnector("filesystem")
.schema(schema)
.option("path", "file:///tmp/flink")
.format("json")
.build());
// Insert data
tEnv.executeSql("INSERT INTO StaticTable VALUES ('a', 'xxxx'), ('b', 'yyyy')");
}
public static void main(String[] args) throws Exception {
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setRuntimeMode(RuntimeExecutionMode.STREAMING);
final StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
// Start with datastream
DataStreammyPojo source = env.fromElements(new myPojo("a"), new myPojo("b"));
tEnv.createTemporaryView("tempView", source);
// Simulate JDBC table with filesystem table
createStaticTable(tEnv);
// Join with static table
Table result = tEnv.sqlQuery("SELECT * FROM tempView LEFT JOIN StaticTable USING (id)");
DataStreammyPojoExtra ds = tEnv.toDataStream(result, myPojoExtra.class);
ds.print();
// ds.print();
env.execute("");
}
}Martijn Visser
12/27/2023, 8:50 PMMatan Perelmuter
12/27/2023, 10:16 PMYuval Itzchakov
12/28/2023, 5:49 PMds.addSink(new SinkFunction[myPojoExtra] {
override def invoke(value: myPojoExtra, context: SinkFunction.Context): Unit = println(value)
})