What are the actual combat skills of Spark in big data
What this article shares with you is about what the actual combat skills of Spark in big data are. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article. Without saying much, let's follow the editor to have a look.
1. Connect mysql
-- driver-class-path mysql-connector-java-5.1.21.jar
In the database, SET GLOBAL binlog_format=mixed
Udf using Hive in 2.Spark
Use the same-jars
3.Spark jupyter usage
Https://www.jb51.net/article/163641.htm
Https://my.oschina.net/albert2011/blog/754174
Use jupyter-notebook-- ip hostname-I to launch
4.Spark uses hive's orc parsing format
Spark.sql.hive.convertMetastoreOrc=true
The problem of null pointer or data out of bounds may occur when using spark to write data into the hive table, which is caused by the metadata parsing problem of spark rather than hive.
The use of import org.apache.spark.sql.expressions.Windowimport org.apache.spark.sql.functions.row_numberimport org.apache.spark.sql.functions._ for 5.row_number sorting operator
1.spark.sql (sql) .withColumn ("rn", row_number (). Over (Window.partitionBy ('f_trans_id) .orderby (col ("f_modify_time") .desc)) 2.spark.sql (sql) .withColumn ("rn", row_number (). Over (Window.partitionBy (' f_trans_id). OrderBy (- col ("f_modify_time")
3.val df = spark.sql (sql)
Df.withColumn ("rn", row_number () .over (Window.partitionBy ('f_trans_id) .orderBy (- df ("f_modify_time")
4.spark.sql (sql) .withColumn ("rn", row_number (). Over (Window.partitionBy ('f_trans_id). OrderBy (-' f_modify_time)
Note:-the way, after testing, unstable, sometimes yes, sometimes not
6.broadcast broadcast table
Sc.broadcast is broadcast data and is generally used for rdd broadcasts, while the following methods are used for broadcast tables
Import org.apache.spark.sql.functions.broadcast
Broadcast (tableData). CreateOrReplaceTempView
The above is what are the actual combat skills of Spark in big data. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.