L'interface Spark

Introduction à Spark SQL en Python

Mark Plutowski

Data Scientist

Use the Spark UI inspect execution

  • Une tâche Spark est une unité d'exécution qui s'exécute sur un seul processeur

  • Étape Spark un groupe de tâches effectuant le même calcul en parallèle, chaque tâche traitant généralement un sous-ensemble différent des données

  • Travail Spark un calcul déclenché par une action, découpé en une ou plusieurs étapes.

Introduction à Spark SQL en Python

Trouver l'interface Spark

  1. http://[DRIVER_HOST]:4040
  2. http://[DRIVER_HOST]:4041
  3. http://[DRIVER_HOST]:4042
  4. http://[DRIVER_HOST]:4043
    ...
Introduction à Spark SQL en Python

Introduction à Spark SQL en Python

Introduction à Spark SQL en Python

Introduction à Spark SQL en Python

Opérations sur le catalogue Spark

  • spark.catalog.cacheTable('table1')
  • spark.catalog.uncacheTable('table1')
  • spark.catalog.isCached('table1')
  • spark.catalog.dropTempView('table1')
Introduction à Spark SQL en Python

Catalogue Spark

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

Introduction à Spark SQL en Python

Introduction à Spark SQL en Python

Onglet Storage de l'interface Spark

Indique où se trouvent les partitions de données

  • en mémoire,
  • ou sur disque,
  • dans tout le cluster,
  • à un instant donné.
Introduction à Spark SQL en Python

Onglet SQL de l'interface Spark

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()
Introduction à Spark SQL en Python

Introduction à Spark SQL en Python

Introduction à Spark SQL en Python

Introduction à Spark SQL en Python

Introduction à Spark SQL en Python

Passons à la pratique !

Introduction à Spark SQL en Python

Preparing Video For Download...