- pom.xml 配置
<properties>
<java.version>1.8</java.version>
<kettle.version>8.2.0.0-342</kettle.version>
<impala.jdbc.version>2.6.9.1010</impala.jdbc.version>
</properties>
<dependency>
<groupId>org.pentaho</groupId>
<artifactId>kettle-core</artifactId>
<version>${kettle.version}</version>
</dependency>
<dependency>
<groupId>org.pentaho</groupId>
<artifactId>kettle-engine</artifactId>
<version>${kettle.version}</version>
</dependency>
<dependency>
<groupId>org.pentaho</groupId>
<artifactId>kettle-metastore</artifactId>
<version>${kettle.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.scannotation/scannotation -->
<dependency>
<groupId>org.scannotation</groupId>
<artifactId>scannotation</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.pentaho</groupId>
<artifactId>pentaho-big-data-kettle-plugins-hive</artifactId>
<version>${kettle.version}</version>
</dependency>
<dependency>
<groupId>org.pentaho</groupId>
<artifactId>pentaho-big-data-api-jdbc</artifactId>
<version>${kettle.version}</version>
</dependency>
<dependency>
<groupId>Impala</groupId>
<artifactId>ImpalaJDBC41</artifactId>
<version>${impala.jdbc.version}</version>
</dependency>
错误从XML文件读取转换
Unable to load database connection info from XML node
Unable to create new database interface
database type with plugin id [IMPALASIMBA] couldn't be found!
at org.pentaho.di.trans.TransMeta.loadXML(TransMeta.java:3460)
at org.pentaho.di.trans.TransMeta.<init>(TransMeta.java:2809)
at org.pentaho.di.trans.TransMeta.<init>(TransMeta.java:2750)
at org.pentaho.di.trans.TransMeta.<init>(TransMeta.java:2727)
at org.pentaho.di.trans.TransMeta.<init>(TransMeta.java:2707)
at org.pentaho.di.trans.TransMeta.<init>(TransMeta.java:2672)
at org.pentaho.di.trans.TransMeta.<init>(TransMeta.java:2635)
at com.example.test.TestApplicationTests.testEtl2(TestApplicationTests.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: org.pentaho.di.core.exception.KettleXMLException:
错误从XML文件读取转换
Unable to load database connection info from XML node
Unable to create new database interface
database type with plugin id [IMPALASIMBA] couldn't be found!
at org.pentaho.di.trans.TransMeta.loadXML(TransMeta.java:3442)
... 38 more
Caused by: org.pentaho.di.core.exception.KettleXMLException:
Unable to load database connection info from XML node
Unable to create new database interface
database type with plugin id [IMPALASIMBA] couldn't be found!
at org.pentaho.di.core.database.DatabaseMeta.<init>(DatabaseMeta.java:1017)
at org.pentaho.di.trans.TransMeta.loadXML(TransMeta.java:3030)
... 38 more
Caused by: org.pentaho.di.core.exception.KettleXMLException:
Unable to create new database interface
database type with plugin id [IMPALASIMBA] couldn't be found!
at org.pentaho.di.core.database.DatabaseMeta.<init>(DatabaseMeta.java:981)
... 39 more
Caused by: org.pentaho.di.core.exception.KettleDatabaseException:
database type with plugin id [IMPALASIMBA] couldn't be found!
at org.pentaho.di.core.database.DatabaseMeta.findDatabaseInterface(DatabaseMeta.java:588)
at org.pentaho.di.core.database.DatabaseMeta.getDatabaseInterface(DatabaseMeta.java:562)
at org.pentaho.di.core.database.DatabaseMeta.<init>(DatabaseMeta.java:978)
System.setProperty(“KETTLE_PLUGIN_BASE_FOLDERS”, “D:\plugins”);
kettle 会自动扫描路径下面的插件以JAR形式加载
重写
引入org.pentaho.big.data.kettle.plugins.hive
@DatabaseMetaPlugin(type = "IMPALASIMBA", typeDescription = "Cloudera Impala")
public class ImpalaSimbaDatabaseMeta
public ImpalaSimbaDatabaseMeta() {
this(new DriverLocator()
{
public Driver getDriver(String arg0)
{
return null; }
});
}
开发
@Test
public void testEtl2() {
try {
String impalatomysql = "D:\\kettledev\\ktr\\impalatomysql.ktr";
System.setProperty("KETTLE_PLUGIN_BASE_FOLDERS", "D:\\plugins");
KettleEnvironment.init();
TransMeta transMeta = new TransMeta(impalatomysql);
Trans trans = new Trans(transMeta);
// 设置变量(这些变量可以在.ktl中通过${variableName}来引用)
String beginTime = "2019-04-02 00:00:00";
String endTime = "2019-04-06 23:59:59";
trans.setVariable("beginTime", beginTime);
trans.setVariable("endTime", endTime);
trans.execute(null);
trans.waitUntilFinished();
Result result = trans.getResult();
} catch (KettleException e) {
e.printStackTrace();
}
}