在利用sqoop1.99.7做数据迁移的时候,从mysql导出表格到hive建立对应的表格,字段中使用了timestamp类型,在读取数据的时候,发现数据为null。查找问题方法如下:
1、查询库表字段类型 命令:desc tablename
![](https://file.jishuzhan.net/article/1773998085366616065/20ebe6cd5c38a1585916344d9a6b712a.webp)
2、查看hive数据库中数据情况,如下图说是,时间字段是以字符串形式存储的。
![](https://file.jishuzhan.net/article/1773998085366616065/53d66154fff5af6254753a896e77a01a.webp)
3、在hive shell查询数据,发现时间字段为null,如下图所示:
![](https://file.jishuzhan.net/article/1773998085366616065/49a9fc8c627b5dab8cc35da9fae9e453.webp)
解决方法
修改表格字段数据类型,命令:alter table tablename change column columnname new columnname datatype;
![](https://file.jishuzhan.net/article/1773998085366616065/9301554c9ea41f9c121a63c08e34a3d5.webp)
再次在hive shell中查询数据,成功查询到数据
![](https://file.jishuzhan.net/article/1773998085366616065/32d405b781f2d185307a13c5df446df6.webp)