impala JDBC连接impala表(impala和kudu关联表)进行upsert,delete操作,upsert操作没有任何问题,但是delete操作报错,完整错误如下:
[Simba][ImpalaJDBCDriver](500323) Error processing query translation statement.
java.sql.SQLException: [Simba][ImpalaJDBCDriver](500323) Error processing query translation statement.
at com.cloudera.impala.querytranslation.ImpalaQueryTranslator.translate(Unknown Source)
at com.cloudera.impala.querytranslation.ImpalaQueryTranslator.translate(Unknown Source)
at com.cloudera.hivecommon.dataengine.HiveJDBCQueryExecutorWithLimitZeroPreparedStatementMetadata.execute(Unknown Source)
at com.cloudera.jdbc.common.SPreparedStatement.executeWithParams(Unknown Source)
at com.cloudera.jdbc.common.SPreparedStatement.execute(Unknown Source)
at com.miaoke.flink.utils.impala.ImpalaUtil$$anonfun$execute$1.apply(ImpalaUtil.scala:59)
at com.miaoke.flink.utils.impala.ImpalaUtil$$anonfun$execute$1.apply(ImpalaUtil.scala:53)
at com.xx.flink.utils.base.LoanPattern$class.using(LoanPattern.scala:21)
at com.xx.flink.utils.base.LoanPattern$.using(LoanPattern.scala:9)
at com.xx.flink.utils.impala.ImpalaUtil$.execute(ImpalaUtil.scala:53)
at com.xx.flink.utils.impala.ImpalaUtil$.upsert(ImpalaUtil.scala:329)
at xx.MmsTest$$anonfun$1.apply$mcZ$sp(MmsTest.scala:17)
at xx.MmsTest$$anonfun$1.apply(MmsTest.scala:17)
at xx.MmsTest$$anonfun$1.apply(MmsTest.scala:17)
at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
at org.scalatest.Transformer.apply(Transformer.scala:22)
at org.scalatest.Transformer.apply(Transformer.scala:20)
at org.scalatest.FunSuiteLike$$anon$1.apply(FunSuiteLike.scala:186)
at org.scalatest.TestSuite$class.withFixture(TestSuite.scala:196)
at org.scalatest.FunSuite.withFixture(FunSuite.scala:1560)
at org.scalatest.FunSuiteLike$class.invokeWithFixture$1(FunSuiteLike.scala:183)
at org.scalatest.FunSuiteLike$$anonfun$runTest$1.apply(FunSuiteLike.scala:196)
at org.scalatest.FunSuiteLike$$anonfun$runTest$1.apply(FunSuiteLike.scala:196)
at org.scalatest.SuperEngine.runTestImpl(Engine.scala:289)
at org.scalatest.FunSuiteLike$class.runTest(FunSuiteLike.scala:196)
at org.scalatest.FunSuite.runTest(FunSuite.scala:1560)
at org.scalatest.FunSuiteLike$$anonfun$runTests$1.apply(FunSuiteLike.scala:229)
at org.scalatest.FunSuiteLike$$anonfun$runTests$1.apply(FunSuiteLike.scala:229)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:396)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:384)
at scala.collection.immutable.List.foreach(List.scala:381)
at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:384)
at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:379)
at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:461)
at org.scalatest.FunSuiteLike$class.runTests(FunSuiteLike.scala:229)
at org.scalatest.FunSuite.runTests(FunSuite.scala:1560)
at org.scalatest.Suite$class.run(Suite.scala:1147)
at org.scalatest.FunSuite.org$scalatest$FunSuiteLike$$super$run(FunSuite.scala:1560)
at org.scalatest.FunSuiteLike$$anonfun$run$1.apply(FunSuiteLike.scala:233)
at org.scalatest.FunSuiteLike$$anonfun$run$1.apply(FunSuiteLike.scala:233)
at org.scalatest.SuperEngine.runImpl(Engine.scala:521)
at org.scalatest.FunSuiteLike$class.run(FunSuiteLike.scala:233)
at org.scalatest.FunSuite.run(FunSuite.scala:1560)
at org.scalatest.tools.SuiteRunner.run(SuiteRunner.scala:45)
at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$1.apply(Runner.scala:1340)
at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$1.apply(Runner.scala:1334)
at scala.collection.immutable.List.foreach(List.scala:381)
at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:1334)
at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1011)
at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1010)
at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:1500)
at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:1010)
at org.scalatest.tools.Runner$.run(Runner.scala:850)
at org.scalatest.tools.Runner.run(Runner.scala)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:138)
Caused by: com.cloudera.support.exceptions.GeneralException: [Simba][ImpalaJDBCDriver](500323) Error processing query translation statement.
... 56 more
删除语句是:delete from user where rowkey='1001'
我用的impala jdbc驱动是2.5.42,解决办法有两个:
1.升级驱动。当前我看的官方最新驱动版本是2.6.4,于是更新到2.6.4就不会报错了。阿里仓库里没有impala jdbc驱动,先去官网把对于版本驱动下下来,然后使用命令:
mvn install:install-file -Dfile=F:/externallib/ImpalaJDBC41-2.6.4.jar -DgroupId=com.cloudera -DartifactId=ImpalaJDBC41 -Dversion=2.6.4 -Dpackaging=jar
加到本地仓库,在maven中就可以正常使用了。
2.删除语句加一个分号,如下:
connection.prepareStatement("delete from user where rowkey='1001';")
算是impala的一个小bug吧。
maven配置:
<dependency> <groupId>com.cloudera</groupId> <artifactId>ImpalaJDBC41</artifactId> <version>2.6.4</version> </dependency>