【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 [email protected]:pentaho/pentaho-kettle.git
# hadoop-plugin
git clone -b 9.2.0.0-R [email protected]: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类型

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

相关推荐
IvanCodes3 小时前
六、Hive 分桶
大数据·hive
IvanCodes3 小时前
七、深入 Hive DDL:管理表、分区与洞察元数据
数据仓库·hive·hadoop
七七-d3 小时前
配置Hadoop集群-上传文件
大数据·hadoop·eclipse
若兰幽竹4 小时前
【HBase整合Hive】HBase-1.4.8整合Hive-2.3.3过程
数据库·hive·hbase
lix的小鱼5 小时前
安装Hadoop并运行WordCount程序
大数据·linux·hadoop
Freedom℡9 小时前
使用scp命令拷贝hadoop100中文件到其他虚拟机中
数据库·hadoop·spark
依年南台9 小时前
Hadoop的目录结构和组成
大数据·hadoop·分布式
依年南台12 小时前
安装Hadoop并运行WordCount程序
大数据·hadoop
依年南台14 小时前
Spark处理过程-案例数据清洗
大数据·hadoop
Agatha方艺璇1 天前
MapReduce报错 HADOOP_HOME and hadoop.home.dir are unset.
大数据·hadoop·mapreduce