De Spark UI

Introductie tot Spark SQL in Python

Mark Plutowski

Data Scientist

Gebruik de Spark UI om uitvoering te inspecteren

  • Een Spark-taak (Task) is een uitvoereenheid die op één cpu draait

  • Een Spark-fase (Stage) is een groep taken die dezelfde berekening parallel uitvoeren, elk meestal op een andere subset van de data

  • Een Spark-job is een berekening getriggerd door een actie, opgedeeld in één of meer stages.

Introductie tot Spark SQL in Python

De Spark UI vinden

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

Introductie tot Spark SQL in Python

Introductie tot Spark SQL in Python

Introductie tot Spark SQL in Python

Spark-catalogusbewerkingen

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

Spark-catalogus

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

Introductie tot Spark SQL in Python

Introductie tot Spark SQL in Python

Spark UI-tabblad Storage

Toont waar datapartities staan

  • in het geheugen,
  • of op schijf,
  • over het cluster,
  • op een momentopname.
Introductie tot Spark SQL in Python

Spark UI-tabblad SQL

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()
Introductie tot Spark SQL in Python

Introductie tot Spark SQL in Python

Introductie tot Spark SQL in Python

Introductie tot Spark SQL in Python

Introductie tot Spark SQL in Python

Laten we oefenen!

Introductie tot Spark SQL in Python

Preparing Video For Download...