当前位置:网站首页>09-Partitioning
09-Partitioning
2022-04-22 19:09:00 【wangyanglongcc】
Get partitions and cores
Use an rdd method to get the number of DataFrame partitions
df = spark.read.parquet(eventsPath)
df.rdd.getNumPartitions()

Access SparkContext through SparkSession to get the number of cores or slots
SparkContext is also provided in Databricks notebooks as the variable sc
print(spark.sparkContext.defaultParallelism)
# print(sc.defaultParallelism)
# return 8
Repartition DataFrame
repartition
Returns a new DataFrame that has exactly n partitions.
repartitionedDF = df.repartition(8)
repartitionedDF.rdd.getNumPartitions()

coalesce
Returns a new DataFrame that has exactly n partitions, when the fewer partitions are requested
If a larger number of partitions is requested, it will stay at the current number of partitions
coalesceDF = df.coalesce(8)
coalesceDF.rdd.getNumPartitions()

Configure default shuffle partitions
Use SparkConf to access the spark configuration parameter for default shuffle partitions
spark.conf.get("spark.sql.shuffle.partitions")

Configure default shuffle partitions to match the number of cores
spark.conf.set("spark.sql.shuffle.partitions", "8")
Adaptive Query Execution
Spark SQL can use spark.sql.adaptive.enabled to control whether AQE is turned on/off (disabled by default)
spark.conf.get("spark.sql.adaptive.enabled")
版权声明
本文为[wangyanglongcc]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_33246702/article/details/124341314
边栏推荐
- 第三次作业解析
- The beautiful and comfortable kn95 mask has strong protection ability
- 2019-11-19 solve the problem that go test executes a single test file and prompts undefined
- 防火门可以根据EN 1634-1 标准测试吗?
- How to build the campus running platform?
- Aicoco AI frontier promotion (4.22)
- System Analyst - paper writing framework construction
- 小型LED屏/数字闹钟显示屏/LED广告牌/温度数字显示器等LED数码管显示驱动IC-VK1640/1640B SOP28/SSOP24封装
- Data time-sharing market, data backup and individual stock rise and fall development of today's index items [11]
- CMS垃圾收集器和G1垃圾收集器
猜你喜欢
随机推荐
关于字符串常量池,intern方法的理解
Introduction to feign, a microservice invocation component
Project training - Design and development of 2D multiplayer fighting game based on unity (v. use audiomixer to control the volume)
Type of Flink window
指纹识别记录
漂亮舒服的KN95口罩,防护能力也很强
Take you to understand the principle of highly flexible spark architecture
LC刷题第四天
ReDet 代码逐行解读
Introduction to high performance key value database redis
Mysql索引
如何写一篇五彩斑斓的博客.append(可爱)
高德Flutter官方组件amap_flutter_map在地图上画圆
项目实训- 基于unity的2D多人乱斗闯关游戏设计与开发(三、Unity PlasticSCM多人协同)
The 14th issue of HMS core discovery reviews the long article | enjoy the silky clip and release the creativity of the video
yes. Net future
1372:小明的账单
XML file input of Chapter 13 of kettle paoding jieniu
Network security -- the use of burp suite packet capture tool
被删除的相片能恢复吗?3个技巧恢复被删除的相片








![[TCP] TCP three handshakes and four waves](/img/d1/20252b9d83730ca6c6cfa06673eacb.png)