【pentaho】kettle读取Hive表不支持bigint和timstamp类型解决。

一、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包中。

java 复制代码
        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分两种 signedunsigned 的 就是 有正负的和 仅正的。

当是unsigned时候kettle任务jdbc应提供为decimal类型(java 中是bigdecimal类型)的数据。这种仅仅是很难遇到的临界状态场景,其实可以忽略,所以把此判断去除直接让hive的bigint 都转为kettle的TYPE_INTEGER 就可以。

可能需要编译kettle源码:
仅处理bigint问题不需要pentaho-hadoop-shims项目的编译!!!这里仅作pentaho-hadoop-shims的记录而已。

shell 复制代码
# 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-kettlepentaho-hadoop-shims搜索选择,自己已经在用的版本或者-R release版本即可。

根据自己的kettle主版本选择hadoop-plugin版本。

项目根目录的pom.xml需要配置仓库地址:

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类型

修改数据库连接的高级配置即可。

相关推荐
CHICX12293 小时前
【Hadoop】改一下core-site.xml和hdfs-site.xml配置就可以访问Web UI
xml·大数据·hadoop
极客先躯11 小时前
Hadoop krb5.conf 配置详解
大数据·hadoop·分布式·kerberos·krb5.conf·认证系统
BD_Marathon17 小时前
设置hive本地模式
数据仓库·hive·hadoop
Data 31717 小时前
Hive数仓操作(十一)
大数据·数据库·数据仓库·hive·hadoop
Data 31719 小时前
Hive数仓操作(九)
大数据·数据仓库·hive·hadoop
晚睡早起₍˄·͈༝·͈˄*₎◞ ̑̑19 小时前
JavaWeb(二)
java·数据仓库·hive·hadoop·maven
朗朗乾坤.py1 天前
Hadoop HDFS命令操作实例
hadoop·hdfs·npm
杰哥在此1 天前
Python知识点:如何使用Hadoop与Python进行大数据处理
开发语言·hadoop·python·面试·编程
Data 3171 天前
Hive数仓操作(三)
大数据·数据库·数据仓库·hive·hadoop