2017-08-16 292 views
0

嗨,大家好,我是pentaho新手,使用pentaho kettle version 7.1mysql jdbc driver版本是5.1.43。我在不同的数据库中有两个相同的表。我们叫db1是第一个在生产中托管的数据库,而db2是另一个在开发中托管的数据库。 db1db2都有相同的表,称为dashboard_user。表dashboard_user有主键id这是autoincrement。但问题是,当我试图从生产,而不删除现有的数据在发展中复制值来发展它返回象下面这样:Pentaho错误:非主键重复条目

017/08/16 15:13:02 - Table output.0 - Connected to database [localhost] (commit=1000) 2017/08/16 15:13:02 - Table output.0 - ERROR (version 7.1.0.0-12, build 1 from 2017-05-16 17.18.02 by buildguy) : Because of an error, this step can't continue: 2017/08/16 15:13:02 - Table output.0 - ERROR (version 7.1.0.0-12, build 1 from 2017-05-16 17.18.02 by buildguy) : org.pentaho.di.core.exception.KettleException: 2017/08/16 15:13:02 - Table output.0 - Error inserting row into table [dashboard_domains] with values: [sonar.id], [2016/07/17 07:27:31.000000000], [2017/07/25 08:08:26.000000000] 2017/08/16 15:13:02 - Table output.0 - 2017/08/16 15:13:02 - Table output.0 - Error inserting/updating row 2017/08/16 15:13:02 - Table output.0 - Duplicate entry 'sonar.id' for key 'index_dashboard_domains_on_domain' 2017/08/16 15:13:02 - Table output.0 - 2017/08/16 15:13:02 - Table output.0 - 2017/08/16 15:13:02 - Table output.0 - at org.pentaho.di.trans.steps.tableoutput.TableOutput.writeToTable(TableOutput.java:385) 2017/08/16 15:13:02 - Table output.0 - at org.pentaho.di.trans.steps.tableoutput.TableOutput.processRow(TableOutput.java:125) 2017/08/16 15:13:02 - Table output.0 - at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62) 2017/08/16 15:13:02 - Table output.0 - at java.lang.Thread.run(Thread.java:748) 2017/08/16 15:13:02 - Table output.0 - Caused by: org.pentaho.di.core.exception.KettleDatabaseException: 2017/08/16 15:13:02 - Table output.0 - Error inserting/updating row 2017/08/16 15:13:02 - Table output.0 - Duplicate entry 'sonar.id' for key 'index_dashboard_domains_on_domain' 2017/08/16 15:13:02 - Table output.0 - 2017/08/16 15:13:02 - Table output.0 - at org.pentaho.di.core.database.Database.insertRow(Database.java:1321) 2017/08/16 15:13:02 - Table output.0 - at org.pentaho.di.trans.steps.tableoutput.TableOutput.writeToTable(TableOutput.java:262) 2017/08/16 15:13:02 - Table output.0 - ... 3 more 2017/08/16 15:13:02 - Table output.0 - Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'sonar.id' for key 'index_dashboard_domains_on_domain' 2017/08/16 15:13:02 - Table output.0 - at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 2017/08/16 15:13:02 - Table output.0 - at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 2017/08/16 15:13:02 - Table output.0 - at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 2017/08/16 15:13:02 - Table output.0 - at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 2017/08/16 15:13:02 - Table output.0 - at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) 2017/08/16 15:13:02 - Table output.0 - at com.mysql.jdbc.Util.getInstance(Util.java:408) 2017/08/16 15:13:02 - Table output.0 - at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:935) 2017/08/16 15:13:02 - Table output.0 - at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973) 2017/08/16 15:13:02 - Table output.0 - at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909) 2017/08/16 15:13:02 - Table output.0 - at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527) 2017/08/16 15:13:02 - Table output.0 - at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680) 2017/08/16 15:13:02 - Table output.0 - at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2494) 2017/08/16 15:13:02 - Table output.0 - at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858) 2017/08/16 15:13:02 - Table output.0 - at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2079) 2017/08/16 15:13:02 - Table output.0 - at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2013) 2017/08/16 15:13:02 - Table output.0 - at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5104) 2017/08/16 15:13:02 - Table output.0 - at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1998) 2017/08/16 15:13:02 - Table output.0 - at org.pentaho.di.core.database.Database.insertRow(Database.java:1288) 2017/08/16 15:13:02 - Table output.0 - ... 4 more 2017/08/16 15:13:02 - Table output.0 - Finished processing (I=0, O=0, R=1, W=0, U=0, E=1)

它说:

Error inserting/updating row 2017/08/16 15:13:02 - Table output.0 - Duplicate entry 'sonar.id' for key 'index_dashboard_domains_on_domain' 2017/08/16 15:13:02 - Table output.0 - 2017/08/16 15:13:02 - Table output.0 - 2017/08/16 15:13:02 - Table output.0 - at org.pentaho.di.trans.steps.tableoutput.TableOutput.writeToTable(TableOutput.java:385)

sonar.id是用户名,而不是主键,我想知道为什么我无法传输数据?但返回错误,说重复的键?

回答

0

它试图完成它告诉你的事情:插入带有重复ID的密钥。

第一种解决方法是在再次插入记录之前删除(截断)输出表。

第二种解决方案是将Output table与错误处理程序一起使用:放入Dummy步骤并在定义跳跃/箭头时选择错误处理。此步骤将收到所有错误,包括重复项。

第三种解决方案是用CRUD进行增量加载。该步骤被命名为Joins/Merge Row (diff)。您可以指定参考(现有)数据和新输入数据,以及要比较的关键字。然后,水壶创建一个新的字段,其中包含“新”,“删除”,“相同”或“更新”,从中只能过滤新数据。

enter image description here