一、bigint类型
报错:
Unable to get value 'BigNumber(16)' from database resultset
显示kettle认为此应该是decimal类型(kettle中是TYPE_BIGNUMBER或称BigNumber),但实际hive数据库中是big类型。
修改kettle源码解决:
kettle中java.sql.Types
到kettle类型转换的方法是org.pentaho.di.core.row.value.ValueMetaBase#getValueFromSQLType
类在data-integration
中的data-integration-9.2.0.4-R\lib\kettle-core-***.jar
包中。
case java.sql.Types.BIGINT:
// verify Unsigned BIGINT overflow!
// TODO:fix kettle read hudi bigint: Unable to get value 'BigNumber(16)' from database resultset
// force to be unsigned bigint type!!!
/* if ( signed ) {
valtype = ValueMetaInterface.TYPE_INTEGER;
precision = 0; // Max 9.223.372.036.854.775.807
length = 15;
} else {
valtype = ValueMetaInterface.TYPE_BIGNUMBER;
precision = 0; // Max 18.446.744.073.709.551.615
length = 16;
}*/
// add code
valtype = ValueMetaInterface.TYPE_INTEGER;
precision = 0; // Max 9.223.372.036.854.775.807
length = 15;
break;
本质就是kettle认为bigint分两种 signed
和 unsigned
的 就是 有正负的和 仅正的。
当是unsigned
时候kettle任务jdbc应提供为decimal类型(java 中是bigdecimal类型)的数据。这种仅仅是很难遇到的临界状态场景,其实可以忽略,所以把此判断去除直接让hive的bigint
都转为kettle的TYPE_INTEGER
就可以。
方法一:直接编译:
# 将kettle-core安装本地到mvn仓库中
mvn install:install-file -DgroupId=pentaho-kettle -DartifactId=kettle-core -Dversion=8.2.0.0-342 -Dpackaging=jar -Dfile=kettle-home\lib\kettle-core-*.jar
新建maven项目:
引入依赖,就这一个依赖就够用了:
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
<version>8.2.0.0-342</version>
<scope>provided</scope>
</dependency>
新建 路径:org.pentaho.di.core.row.value
并将 kettle-core-*.jar
包中的 ValueMetaBase
反编译源码粘贴到此路径下。
修改case -5:
把 if 啥的删掉替换成如下内容即可。
// java.sql.Types.BIGINT --> -5, 编译的时候java直接用字面值替换了变量了。
case -5:
valtype = 5;
precision = 0;
length = 15;
break;
然后直接mvn package
。从编译好的包中再取到ValueMetaBase
替换kettle-core-*.jar
包中的类,最后把此包替换会kettle-home/lib包即可。
方法二:编译kettle源码(作废):
2024年1月3日日立的maven仓库已经连不上了,有授权!!
仅处理bigint问题不需要pentaho-hadoop-shims项目的编译!!!
这里仅作pentaho-hadoop-shims
的记录而已。
# kettle
git clone -b 9.2.0.0-R git@github.com:pentaho/pentaho-kettle.git
# hadoop-plugin
git clone -b 9.2.0.0-R git@github.com:pentaho/pentaho-hadoop-shims.git
登录github直接在pentaho-kettle
和pentaho-hadoop-shims
搜索选择,自己已经在用的版本或者-R
release版本即可。
根据自己的kettle主版本选择hadoop-plugin版本。
项目根目录的pom.xml需要配置仓库地址:
<repositories>
<repository>
<id>pentaho</id>
<name>pentaho</name>
<url>https://repo.orl.eng.hitachivantara.com/artifactory/pnt-mvn/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>cloudera</id>
<name>cloudera</name>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>pentaho-plugin</id>
<name>pentaho-plugin</name>
<url>https://repo.orl.eng.hitachivantara.com/artifactory/pnt-mvn/</url>
</pluginRepository>
</pluginRepositories>
如果依赖都能下载到,那么直接mvn clean install "-DskipTests"
即可。我编译比较顺利没什么坑。
二、timestamp类型
修改数据库连接的高级配置即可。