sqoop job运行完成之后,发现为tinyint类型的一类始终没有值,经检查发现上游mysql有值,再查看hdfs文件,发现这列被抓换为了boolean类型

搜索一下发现有人碰到过了,以下原文来自https://blog.csdn.net/Fenggms/article/details/84527824

首先,来一段官网原文:

27.2.5. MySQL: Import of TINYINT(1) from MySQL behaves strangely
Problem: Sqoop is treating TINYINT(1) columns as booleans, which is for example causing issues with HIVE import. This is because by default the MySQL JDBC connector maps the TINYINT(1) to java.sql.Types.BIT, which Sqoop by default maps to Boolean.

Solution: A more clean solution is to force MySQL JDBC Connector to stop converting TINYINT(1) to java.sql.Types.BIT by adding tinyInt1isBit=false into your JDBC path (to create something like jdbc:mysql://localhost/test?tinyInt1isBit=false). Another solution would be to explicitly override the column mapping for the datatype TINYINT(1) column. For example, if the column name is foo, then pass the following option to Sqoop during import: --map-column-hive foo=tinyint. In the case of non-Hive imports to HDFS, use --map-column-java foo=integer.

附官网链接:
https://sqoop.apache.org/docs/1.4.6/SqoopUserGuide.html
解释:
问题:
Mysql中存在tinyint(1)时,在数据导入到HDFS时,该字段默认会被转化为boolean数据类型。导致数据内容丢失。
解决方案:
1 在jdbc的连接后面加上:tinyInt1isBit=false
–connect jdbc:mysql://192.168.9.80:3306/kgc_behivour_log?tinyInt1isBit=false

2 另外,还有一种解决方案是显式覆盖数据类型TINYINT(1)列的列映射。例如,如果列名为foo,则在导入期间将以下选项传递给Sqoop: – map-column-hive foo = tinyint。
在非Hive导入HDFS的情况下,使用–map-column-java foo = integer

最新文章

  1. BootStrap学习笔记,优缺点总结
  2. .Net中DataAdapter批量插入和更新数据总结
  3. java-汉字转换拼音-pinyin4j.jar
  4. 对div作用域的理解
  5. 让你的CI跑起来-《持续集成》读书总结
  6. mysql 基本使用教程(源于网络)
  7. openSUSE13.1无法打开Yast的安装/移除软件管理软件的解决办法·(未解决,临时方法) 收获:有问题,读日志
  8. Laravel-表单篇-零散信息
  9. POJ 2195 Going Home / HDU 1533(最小费用最大流模板)
  10. objective -c こだわり
  11. Java线程:什么是线程
  12. IP路由及静态路由配置
  13. linux中sogou输入法崩溃重启
  14. java-初识引用分类及Map实现类WeakHashMap
  15. Git Bash的妙用 - 使用Linux命令
  16. XShell发送命令到全部会话
  17. Study 5 —— CSS概述
  18. python的反射函数(hasattr()、getattr()、setattr()与delattr())和类的内置属性attr(__getattr()__、__setattr()__与__delattr()__)
  19. .Net Core Api 跨域配置
  20. Apache Rewrite规则详解

热门文章

  1. mybatis-plus之Mapper CRUD接口和 Service CRUD 接口
  2. Java - HashMap值大于128问题
  3. 一个支持DbFirst、ModelFirst和CodeFirst的数据库小工具DbTool
  4. wcf和webapi(转)
  5. MyBatis入门(一)—— 入门案例
  6. POJ3278(KB1-C 简单搜索)
  7. BZOJ2663 [Beijing wc2012]灵魂宝石
  8. JavaScript、HTML、CSS学习—思维导图
  9. OG数据预处理
  10. Android网络请求库RetrofitUtils