【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包中。

        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的记录而已。

# 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需要配置仓库地址:

    <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. TCP协议是安全的吗?

    2023-12-22 09:58:04       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-22 09:58:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-22 09:58:04       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-22 09:58:04       20 阅读

热门阅读

  1. 2866. 美丽塔 II(单调栈)

    2023-12-22 09:58:04       49 阅读
  2. 技术面试的斗智斗勇III

    2023-12-22 09:58:04       43 阅读
  3. Lua脚本在Redis中的高效应用

    2023-12-22 09:58:04       51 阅读
  4. LeetCode day29

    2023-12-22 09:58:04       55 阅读
  5. 基于OpenCV的视频流处理方法

    2023-12-22 09:58:04       41 阅读
  6. vue和react diff的详解和不同

    2023-12-22 09:58:04       50 阅读
  7. 前端八股文(vue篇)

    2023-12-22 09:58:04       42 阅读
  8. HTML中的6种空格标记

    2023-12-22 09:58:04       43 阅读
  9. WPF DataGrid行渲染

    2023-12-22 09:58:04       47 阅读
  10. HTMLCSS旋转的圣诞树源码附注释

    2023-12-22 09:58:04       41 阅读