Thijs van de Poll
03/13/2023, 7:04 PMCREATE TABLE group (
group_id INT NOT NULL,
representative INT,
score INT,
PRIMARY KEY (group_id) NOT ENFORCED
) WITH (
'connector' = 'jdbc',
'url' = 'jdbc:<postgresql://host.docker.internal:5432/doc_data>',
'table-name' = 'xml.t_group',
'username' = 'root',
'password' = 'root',
'driver' = 'org.postgresql.Driver'
);
The insert statement:
INSERT INTO group (group_id, representative, score) SELECT * FROM tmp_docs
ON CONFLICT (group_id) DO UPDATE SET
representative = CASE WHEN group.score >= tmp_docs.score THEN group.representative ELSE tmp_docs.representative;
According to the JDBC docs this is how to do it in Postgres https://nightlies.apache.org/flink/flink-docs-release-1.16/docs/connectors/table/jdbc/
But instead of it working, I get the following error message:
org.apache.flink.table.api.SqlParserException: SQL parse failed. Incorrect syntax near the keyword 'ON'
Or does it mean that Flink uses this logic internally, and it it not possible to customize the ON CONFLICT clause?Martijn Visser
03/13/2023, 7:06 PMThijs van de Poll
03/13/2023, 7:08 PMThijs van de Poll
03/13/2023, 7:31 PMsql_dml_statement could work in this case? See https://nightlies.apache.org/flink/flink-docs-release-1.16/docs/connectors/datastream/jdbc/.
Will try it out.sap1ens
03/13/2023, 8:36 PMsap1ens
03/13/2023, 8:37 PMThijs van de Poll
03/13/2023, 8:43 PMThijs van de Poll
03/13/2023, 9:27 PMsap1ens
03/13/2023, 9:33 PMThijs van de Poll
03/13/2023, 10:44 PMpyflink.util.exceptions.TableException: 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 TableSourceScansap1ens
03/13/2023, 10:49 PMThijs van de Poll
03/13/2023, 10:57 PM<http://table_env.to|table_env.to>_changelog_stream which converts the changelog to a data stream. It seems to be working now!Thijs van de Poll
03/13/2023, 11:10 PM