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

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

相关推荐
随心............1 天前
在开发过程中遇到问题如何解决,以及两个经典问题
hive·hadoop·spark
yumgpkpm2 天前
CMP (类ClouderaCDP7.3(404次编译) )华为鲲鹏Aarch64(ARM)信创环境 查询2100w行 hive 查询策略
数据库·数据仓库·hive·hadoop·flink·mapreduce·big data
K_i1342 天前
Hadoop 集群自动化运维实战
运维·hadoop·自动化
Q26433650233 天前
【有源码】基于Python与Spark的火锅店数据可视化分析系统-基于机器学习的火锅店综合竞争力评估与可视化分析-基于用户画像聚类的火锅店市场细分与可视化研究
大数据·hadoop·python·机器学习·数据分析·spark·毕业设计
starfalling10243 天前
【hive】一种高效增量表的实现
hive
顧棟3 天前
【Yarn实战】Yarn 2.9.1滚动升级到3.4.1调研与实践验证
hadoop·yarn
D明明就是我3 天前
Hive 拉链表
数据仓库·hive·hadoop
嘉禾望岗5033 天前
hive join优化和数据倾斜处理
数据仓库·hive·hadoop
yumgpkpm3 天前
华为鲲鹏 Aarch64 环境下多 Oracle 数据库汇聚操作指南 CMP(类 Cloudera CDP 7.3)
大数据·hive·hadoop·elasticsearch·zookeeper·big data·cloudera
忧郁火龙果3 天前
六、Hive的基本使用
数据仓库·hive·hadoop