DTStack / flinkStreamSQL

基于开源的flink,对其实时sql进行扩展;主要实现了流与维表的join,支持原生flink SQL所有的语法
Apache License 2.0
2.02k stars 926 forks source link

输出到外部mysql表replace的支持问题 #13

Closed nuaabuaa07 closed 5 years ago

nuaabuaa07 commented 6 years ago

项目目前支持输出到外部mysql表,使用replace操作吗?比如主键冲突时直接覆盖更新。我测试试,貌似只支持insert into 操作。

yangsishu commented 6 years ago

是用replace into 操作

nuaabuaa07 commented 6 years ago

我使用的是core模块里面的测试案例SideSqlExecTest.class提交测试的。测试中发现。 1.当mysql中设置了主键,使用“insert into”操作,会覆盖更新mysql表里相应主键的条目。 2.无论mysql中设置主键还是取消主键,使用“replace into”操作都会报错。 sql语句如下: replace into MyResult select count(1) as id, MyTable.name from MyTable group by MyTable.name;

错误提示如下: image

yangsishu commented 6 years ago

语法你只能写insert into,但是底层mysql的操作是replace into 操作

nuaabuaa07 commented 6 years ago

明白了。

harbby commented 6 years ago

最好能允许 用户自己填写语句; 如: replace into table select '${0}', ifnull((select cnt from table where id = '${0}'),0)+{1} 例如: https://harbby.github.io/project/sylph/zh-cn/docs/intro/quickstart.html#demo1 这样能带给使用者 非常多的灵活性

yangsishu commented 6 years ago

可以考虑

zhangzaixuan commented 4 years ago

结果表 的声明需要加些特定配置吗