Re: Passing type information to JDBCAppendTableSink

2018-07-05 Thread Rong Rong
+1 to this answer. MERGE is what I found most compatible syntax when dealing with upsert / replace. AFAIK, almost all DBMS have some kind of dialect regrading upsert functionality, so following the SQL standard might be your best solution here. And yes both the MERGE ingestion SQL and the executi

Re: Passing type information to JDBCAppendTableSink

2018-07-04 Thread Fabian Hueske
There is also the SQL:2003 MERGE statement that can be used to implement UPSERT logic. It is a bit verbose but supported by Derby [1]. Best, Fabian [1] https://issues.apache.org/jira/browse/DERBY-3155 2018-07-04 10:10 GMT+02:00 Fabian Hueske : > Hi Chris, > > MySQL (and maybe other DBMS as well

Re: Passing type information to JDBCAppendTableSink

2018-07-04 Thread Fabian Hueske
Hi Chris, MySQL (and maybe other DBMS as well) offers special syntax for upserts. The answers to this SO question [1] recommend "INSERT INTO ... ON DUPLICATE KEY UPDATE ..." or "REPLACE INTO ...". However, AFAIK this syntax is not standardized and might vary from DBMS to DBMS. Best, Fabian [1]

Re: Passing type information to JDBCAppendTableSink

2018-07-03 Thread Chris Ruegger
Fabian, Rong: Thanks for the help, greatly appreciated. I am currently using a Derby database for the append-only JDBC sink. So far I don't see a way to use a JDBC/relational database solution for a retract/upsert use case? Is it possible to set up JDBC sink with Derby or MySQL so that it goes bac

Re: Passing type information to JDBCAppendTableSink

2018-07-03 Thread Fabian Hueske
Hi, In addition to what Rong said: - The types look OK. - You can also use Types.STRING, and Types.LONG instead of BasicTypeInfo.xxx - Beware that in the failure case, you might have multiple entries in the database table. Some databases support an upsert syntax which (together with key or unique

Re: Passing type information to JDBCAppendTableSink

2018-07-01 Thread Rong Rong
Hi Chris, Looking at the code, seems like JDBCTypeUtil [1] is used for converting Flink TypeInformation into JDBC Type (Java.sql.type), and SQL_TIMESTAMP and SQL_TIME are both listed in the conversion mapping. However the JDBC types are different. Regarding the question whether your insert is cor

Re: Passing type information to JDBCAppendTableSink

2018-07-01 Thread chrisr123
Full Source except for mapper and timestamp assigner. Sample Input Stream record: 1530447316589,Mary,./home What are the correct parameters to pass for data types in the JDBCAppendTableSink? Am I doing this correctly? // Get Execution Environment StreamExecut

Re: Passing type information to JDBCAppendTableSink

2018-07-01 Thread miki haiat
can you share the full code . On Sun, Jul 1, 2018 at 12:49 PM chrisr123 wrote: > > I'm trying to determine if I'm specifying type information properly when > doing an INSERT using > the JDBCAppendTableSink API. Specifically, how do I specify timestamp and > date types? It looks like > I need t

Passing type information to JDBCAppendTableSink

2018-07-01 Thread chrisr123
I'm trying to determine if I'm specifying type information properly when doing an INSERT using the JDBCAppendTableSink API. Specifically, how do I specify timestamp and date types? It looks like I need to use Type.SQL_TIMESTAMP for a timestamp but BasicTypeInfo for types like varchar, etc? I a