sqoop import hive parquet表timestamp,decimal转换问题

4 篇文章 0 订阅

1、时间转换问题:timestamp、date,time

以上时间类型会被sqoop转成int,long型,无法直接转成时间类型

1)转成long型,再用from_unixtime转回来,才能看时间(太麻烦)-----parquet表的类型对应为bigint
select *, from_unixtime(cast(SOURCE_LOAD_DATE as BIGINT) DIV 1000000) as SOURCE_LOAD_DATE from table_name;

2)直接转成string型(直观,可以直接看)------parquet表的数据类型对应为string
另外: 处理datetime中有null的情况
在sql connnect中加入:zeroDateTimeBehavior=convertToNull

–connect jdbc:mysql://192.168.1.100/test?zeroDateTimeBehavior=convertToNull

2、浮点类型(float,double,decimal)

sqoop导数据使用avro组件,启用小数(decimal) 必须要加以下参数:

-Dsqoop.avro.decimal_padding.enable=true -Dsqoop.parquet.logical_types.decimal.enable=true
-Dsqoop.avro.logical_types.decimal.default.precision=38
-Dsqoop.avro.logical_types.decimal.default.scale=10

—parquet中对应的数据类型为decimal(precision,scale),如decimal(19,3)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果你的Hive环境启用了LDAP认证,那么在使用Sqoop导入数据时,需要在Sqoop命令中指定Kerberos认证相关参数。 以下是一个示例命令: ``` sqoop import \ --connect jdbc:mysql://hostname:port/dbname \ --username hive \ --password hive_password \ --table table_name \ --hive-import \ --hive-table hive_table_name \ --create-hive-table \ --hive-overwrite \ --hiveconf hive.metastore.uris=thrift://hive-metastore-hostname:9083 \ --hiveconf hive.server2.authentication.kerberos.principal=hive/_HOST@YOUR-REALM.COM \ --hiveconf hive.server2.authentication.kerberos.keytab=/path/to/hive.keytab \ --hiveconf hive.server2.authentication.ldap.url=ldap://ldap-server-hostname:389 \ --hiveconf hive.server2.authentication.ldap.baseDN=dc=ldap,dc=example,dc=com \ --hiveconf hive.server2.authentication.ldap.Domain=ldap.example.com \ --hiveconf hive.server2.authentication.ldap.Group=ldap_group_name \ --hiveconf hive.server2.authentication.ldap.UserDNPattern=uid={0},ou=users,dc=ldap,dc=example,dc=com ``` 其中,需要注意以下几点: 1. `hive.metastore.uris` 参数需要指定Hive metastore的地址,这里使用了thrift协议; 2. `hive.server2.authentication.kerberos.principal` 参数需要指定Hive服务的Kerberos principal名称; 3. `hive.server2.authentication.kerberos.keytab` 参数需要指定Hive服务的Kerberos keytab路径; 4. `hive.server2.authentication.ldap.url` 参数需要指定LDAP服务器的地址和端口号; 5. `hive.server2.authentication.ldap.baseDN` 参数需要指定LDAP根目录的DN; 6. `hive.server2.authentication.ldap.Domain` 参数需要指定LDAP域名; 7. `hive.server2.authentication.ldap.Group` 参数需要指定LDAP中的用户组名称; 8. `hive.server2.authentication.ldap.UserDNPattern` 参数需要指定LDAP中用户的DN格式。 根据实际情况,你需要替换上述命令中的一些参数的值。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值