Giao diện Spark UI

Nhập môn Spark SQL bằng Python

Mark Plutowski

Data Scientist

Dùng Spark UI để kiểm tra thực thi

  • Spark Task: đơn vị thực thi chạy trên một CPU

  • Spark Stage: nhóm tác vụ thực hiện cùng phép tính song song, mỗi tác vụ thường chạy trên một phần dữ liệu khác nhau

  • Spark Job: phép tính được kích hoạt bởi một action, chia thành một hoặc nhiều stage.

Nhập môn Spark SQL bằng Python

Tìm Spark UI

  1. http://[DRIVER_HOST]:4040
  2. http://[DRIVER_HOST]:4041
  3. http://[DRIVER_HOST]:4042
  4. http://[DRIVER_HOST]:4043
    ...
Nhập môn Spark SQL bằng Python

Nhập môn Spark SQL bằng Python

Nhập môn Spark SQL bằng Python

Nhập môn Spark SQL bằng Python

Thao tác với Spark catalog

  • spark.catalog.cacheTable('table1')
  • spark.catalog.uncacheTable('table1')
  • spark.catalog.isCached('table1')
  • spark.catalog.dropTempView('table1')
Nhập môn Spark SQL bằng Python

Spark Catalog

spark.catalog.listTables()
[Table(name='text', database=None, description=None, tableType='TEMPORARY', isTemporary=True)]
Nhập môn Spark SQL bằng Python

Nhập môn Spark SQL bằng Python

Nhập môn Spark SQL bằng Python

Thẻ Storage trong Spark UI

Hiển thị vị trí các phân vùng dữ liệu

  • trong bộ nhớ,
  • trên đĩa,
  • trên toàn cụm,
  • tại một thời điểm.
Nhập môn Spark SQL bằng Python

Thẻ SQL trong 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()
Nhập môn Spark SQL bằng Python

Nhập môn Spark SQL bằng Python

Nhập môn Spark SQL bằng Python

Nhập môn Spark SQL bằng Python

Nhập môn Spark SQL bằng Python

Ayo berlatih!

Nhập môn Spark SQL bằng Python

Preparing Video For Download...