La Spark UI

Introduzione a Spark SQL in Python

Mark Plutowski

Data Scientist

Usa la Spark UI per ispezionare l’esecuzione

  • Un task Spark è un’unità di esecuzione che gira su una singola CPU

  • Uno stage Spark è un gruppo di task che eseguono lo stesso calcolo in parallelo, ciascuno su un sottoinsieme di dati

  • Un job Spark è un’elaborazione avviata da un’azione, divisa in uno o più stage.

Introduzione a Spark SQL in Python

Trovare la Spark UI

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

Introduzione a Spark SQL in Python

Introduzione a Spark SQL in Python

Introduzione a Spark SQL in Python

Operazioni del catalogo Spark

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

Spark Catalog

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

Introduzione a Spark SQL in Python

Introduzione a Spark SQL in Python

Scheda Storage della Spark UI

Mostra dove sono le partizioni dati

  • in memoria,
  • su disco,
  • nel cluster,
  • in un’istantanea temporale.
Introduzione a Spark SQL in Python

Scheda SQL della 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()
Introduzione a Spark SQL in Python

Introduzione a Spark SQL in Python

Introduzione a Spark SQL in Python

Introduzione a Spark SQL in Python

Introduzione a Spark SQL in Python

Ayo berlatih!

Introduzione a Spark SQL in Python

Preparing Video For Download...