Interfața Spark UI

Introducere în Spark SQL în Python

Mark Plutowski

Data Scientist

Utilizați Spark UI pentru a inspecta execuția

  • Task Spark – unitate de execuție care rulează pe un singur CPU

  • Etapă Spark – grup de taskuri care efectuează aceeași computație în paralel, fiecare pe un subset diferit de date

  • Job Spark – computație declanșată de o acțiune, împărțită în una sau mai multe etape.

Introducere în Spark SQL în Python

Găsirea interfeței Spark UI

  1. http://[DRIVER_HOST]:4040
  2. http://[DRIVER_HOST]:4041
  3. http://[DRIVER_HOST]:4042
  4. http://[DRIVER_HOST]:4043
    ...
Introducere în Spark SQL în Python

Introducere în Spark SQL în Python

Introducere în Spark SQL în Python

Introducere în Spark SQL în Python

Operații cu catalogul Spark

  • spark.catalog.cacheTable('table1')
  • spark.catalog.uncacheTable('table1')
  • spark.catalog.isCached('table1')
  • spark.catalog.dropTempView('table1')
Introducere în Spark SQL în Python

Catalogul Spark

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

Introducere în Spark SQL în Python

Introducere în Spark SQL în Python

Fila Storage din Spark UI

Arată unde există partițiile de date

  • în memorie,
  • sau pe disc,
  • în tot clusterul,
  • la un moment dat.
Introducere în Spark SQL în Python

Fila SQL din 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()
Introducere în Spark SQL în Python

Introducere în Spark SQL în Python

Introducere în Spark SQL în Python

Introducere în Spark SQL în Python

Introducere în Spark SQL în Python

Să exersăm!

Introducere în Spark SQL în Python

Preparing Video For Download...