Skip to content

Commit

Permalink
change: 1.更新readme 2.sparksql示例更新了写出的编码方式,防止因为系统环境确实lib报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyofin committed Jun 27, 2019
1 parent aa18692 commit a5ef4b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ SparkSession spark = SparkSession

3.使用`mvn clean package`打包好的作业,并提交到本地安装好的spark环境上跑
```
~/opt/spark-2.4.0-bin-hadoop2.7 » bin/spark-submit --class "com.wugui.sparkstarter.SimpleApp" /Users/huzekang/study/spark-starter/target/spark-starter-1.0-SNAPSHOT.jar
~/opt/spark-2.4.0-bin-hadoop2.7 » bin/spark-submit --class "com.wugui.sparkstarter.SparkHiveNewVersion" /Users/huzekang/study/spark-starter/target/spark-starter-1.0-SNAPSHOT.jar
```
4.打开spark server界面,可以看到已经完成的spark作业。
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/com/wugui/sparkstarter/SparkHiveNewVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ public static void main(String[] args) {
// 定义上下文
SparkSession spark = SparkSession
.builder()
// 如果需要作业要以jar包形式提交到remote spark,则使用spark://host:port
// 如果需要作业要以jar包形式提交到remote spark,则使用spark://host:port
// .master("spark://10.0.0.50:7077")
// 如果idea中测试则使用local。
// 如果作业要以jar包形式提交到yarn则不设置master。

// 如果idea中测试则使用local。
// 如果作业要以jar包形式提交到yarn则不设置master。
.master("local")

.appName("Java Spark SQL Starter !!")
.enableHiveSupport()
.config("spark.some.config.option", "some-value")
// 改变spark sql写出时使用的压缩编码。
// 默认是snappy,可能会在用hive客户端查询时出现错误:
// Caused by: org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] null
.config("spark.sql.parquet.compression.codec", "gzip")
.getOrCreate();

spark.sql("USE default");
Expand Down

0 comments on commit a5ef4b8

Please sign in to comment.