sqoop导出数据export目标mysql数据类型有tinyint异常

sqoop 导出指南
https://sqoop.apache.org/docs...
【sqoop导出数据export目标mysql数据类型有tinyint异常】原文链接防止盗用:https://segmentfault.com/a/11...
简单总结:如果使用sqoop-export导出功能到mysql中,如果mysql中有字段类型是tinyint(1)的话,就会和导入时遇到的问题一样,即tinyint(1)类型值变成了布尔值
解决方法1:mysql字段类型tinyint(1)改成tinyint(2)或者int类型
正常应该是这样
sqoop导出数据export目标mysql数据类型有tinyint异常
文章图片

导出的tinyint(1)异常
sqoop导出数据export目标mysql数据类型有tinyint异常
文章图片

下面为导入的时使用参数,但是没发现有导出时的参数
23.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://segmentfault.com/a/11...

    推荐阅读