Nhập môn Spark SQL bằng Python
Mark Plutowski
Data Scientist
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.



spark.catalog.cacheTable('table1')spark.catalog.uncacheTable('table1')spark.catalog.isCached('table1')spark.catalog.dropTempView('table1')spark.catalog.listTables()
[Table(name='text', database=None, description=None, tableType='TEMPORARY', isTemporary=True)]


Hiển thị vị trí các phân vùng dữ liệu
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