Spark UI

Introduktion till Spark SQL i Python

Mark Plutowski

Data Scientist

Använd Spark UI för att granska körning

  • Spark Task är en körningsenhet som körs på en enda CPU

  • Spark Stage är en grupp uppgifter som utför samma beräkning parallellt, där varje uppgift vanligtvis körs på en annan delmängd av datan

  • Spark Job är en beräkning som utlöses av en åtgärd och delas in i ett eller flera steg.

Introduktion till Spark SQL i Python

Hitta Spark UI

  1. http://[DRIVER_HOST]:4040
  2. http://[DRIVER_HOST]:4041
  3. http://[DRIVER_HOST]:4042
  4. http://[DRIVER_HOST]:4043
    ...
Introduktion till Spark SQL i Python

Introduktion till Spark SQL i Python

Introduktion till Spark SQL i Python

Introduktion till Spark SQL i Python

Spark-katalogoperationer

  • spark.catalog.cacheTable('table1')
  • spark.catalog.uncacheTable('table1')
  • spark.catalog.isCached('table1')
  • spark.catalog.dropTempView('table1')
Introduktion till Spark SQL i Python

Spark Catalog

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

Introduktion till Spark SQL i Python

Introduktion till Spark SQL i Python

Spark UI – fliken Storage

Visar var datapartitioner finns

  • i minnet,
  • eller på disk,
  • i klustret,
  • vid en given tidpunkt.
Introduktion till Spark SQL i Python

Spark UI – fliken 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()
Introduktion till Spark SQL i Python

Introduktion till Spark SQL i Python

Introduktion till Spark SQL i Python

Introduktion till Spark SQL i Python

Introduktion till Spark SQL i Python

Nu kör vi en övning!

Introduktion till Spark SQL i Python

Preparing Video For Download...