Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the actual combat skills of Spark in big data

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report