仅将两个参数传递给 spark 驱动程序和执行程序。
config("spark.executor.extraJavaOptions","-Ddb2.jcc.charsetDecoderEncoder=3")
config("spark.driver.extraJavaOptions","-Ddb2.jcc.charsetDecoderEncoder=3")
具体代码如下
val spark = SparkSession.builder().appName(db_table) // 使用表名作为spark应用名 便于查找
.config("hive.exec.dynamic.partition", "true")
.config("hive.exec.dynamic.partition.mode", "nonstrict")
.config("hive.merge.smallfiles.avgsize", "128000000")
.config("spark.sql.crossJoin.enabled", "true")
.config("spark.executor.extraJavaOptions","-Ddb2.jcc.charsetDecoderEncoder=3")
.config("spark.driver.extraJavaOptions","-Ddb2.jcc.charsetDecoderEncoder=3")
.enableHiveSupport().getOrCreate()