Spark UI

Introduction to Spark SQL in Python

Mark Plutowski

Data Scientist

ใช้ Spark UI ตรวจสอบการประมวลผล

  • Spark Task คือหน่วยการประมวลผลที่รันบน CPU เดียว

  • Spark Stage คือกลุ่มของ Task ที่ทำการคำนวณเดียวกันแบบขนาน โดยแต่ละ Task มักรันบนชุดข้อมูลย่อยที่ต่างกัน

  • Spark Job คือการคำนวณที่ถูกเรียกใช้โดย Action และแบ่งออกเป็นหนึ่ง Stage หรือมากกว่า

Introduction to Spark SQL in Python

การเข้าถึง Spark UI

  1. http://[DRIVER_HOST]:4040
  2. http://[DRIVER_HOST]:4041
  3. http://[DRIVER_HOST]:4042
  4. http://[DRIVER_HOST]:4043
    ...
Introduction to Spark SQL in Python

Introduction to Spark SQL in Python

Introduction to Spark SQL in Python

Introduction to Spark SQL in Python

การดำเนินการ Spark Catalog

  • spark.catalog.cacheTable('table1')
  • spark.catalog.uncacheTable('table1')
  • spark.catalog.isCached('table1')
  • spark.catalog.dropTempView('table1')
Introduction to Spark SQL in Python

Spark Catalog

spark.catalog.listTables()
[Table(name='text', database=None, description=None, tableType='TEMPORARY', isTemporary=True)]
Introduction to Spark SQL in Python

Introduction to Spark SQL in Python

Introduction to Spark SQL in Python

แท็บ Storage ใน Spark UI

แสดงตำแหน่งของ Data Partition

  • ในหน่วยความจำ
  • หรือบนดิสก์
  • กระจายทั่ว Cluster
  • ณ ช่วงเวลาหนึ่ง
Introduction to Spark SQL in Python

แท็บ SQL ใน Spark UI

query3agg = """
SELECT w1, w2, w3, COUNT(*) as count FROM (
   SELECT 
   word AS w1,
   LEAD(word,1) OVER(PARTITION BY part ORDER BY id ) AS w2,
   LEAD(word,2) OVER(PARTITION BY part ORDER BY id ) AS w3
   FROM df
)
GROUP BY w1, w2, w3 
ORDER BY count DESC
""" 

spark.sql(query3agg).show()
Introduction to Spark SQL in Python

Introduction to Spark SQL in Python

Introduction to Spark SQL in Python

Introduction to Spark SQL in Python

Introduction to Spark SQL in Python

มาฝึกกันเถอะ!

Introduction to Spark SQL in Python

Preparing Video For Download...