apache / paimon

Apache Paimon is a lake format that enables building a Realtime Lakehouse Architecture with Flink and Spark for both streaming and batch operations.
https://paimon.apache.org/
Apache License 2.0
2.41k stars 946 forks source link

[Bug] flink cdc sync action can not get the primary key of the new table when we create table by `create table xx like xx` #1613

Closed zhangjun0x01 closed 1 year ago

zhangjun0x01 commented 1 year ago

Search before asking

Paimon version

master

Compute Engine

flink

Minimal reproduce step

  1. start a flink sync job to sync mysql database to paimon
  2. create a mysql table like this:
    
    create table t1 like t0;


### What doesn't meet your expectations?

we can not get primary key and columns of the new table `t1`

### Anything else?

_No response_

### Are you willing to submit a PR?

- [X] I'm willing to submit a PR!
zhangjun0x01 commented 1 year ago

druid can not parse the create table ddl to get primary key and schema in some case, for example:

 1. create table t1(id int primary key, name varchar(10)).  // the primary key following the field 
 2. create table t14 (id int, `name` varchar(10), primary key(id));    //  with quoted 
 3. create table xxx like xxx
 4. create table xxx  as select * from xxx

so I refactor the code by history record to solve these problems