原文链接:https://blog.csdn.net/a904364908/article/details/100627061
案例:使用Sparksql读取MysqL数据tinyint字段经处理后再写出到MysqL后发现,写出的数据全部是数值1,原因是Sparksql内部将tinyint字段数据转换成boolean类型。
1、解决方案:
在JDBC的URL中加入参数:tinyint1isBit=false
val firstOrderDF: DataFrame = spark.read.format("jdbc")
.option("url", "jdbc:MysqL://localhost:3307/test?tinyint1isBit=false")
.option("driver", "com.MysqL.jdbc.Driver")
.option("user", "xxx")
.option("password", "xxx")
.option("dbtable", "xxx")
.load()