CommencerCommencer gratuitement

Practice logging

The following code is executed on startup:

import logging
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG,
                    format='%(levelname)s - %(message)s')

You will now practice these logging operations.

Cet exercice fait partie du cours

Introduction to Spark SQL in Python

Afficher le cours

Instructions

  • Log columns of text_df as debug message.
  • Log whether table1 is cached as info message.
  • Log first row of text_df as warning message.
  • Log selected columns of text_df as error message.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Log columns of text_df as debug message
____("text_df columns: %s", text_df.columns)

# Log whether table1 is cached as info message
____("table1 is cached: %s", spark.catalog.isCached(tableName="table1"))

# Log first row of text_df as warning message
____("The first row of text_df:\n %s", text_df.first())

# Log selected columns of text_df as error message
____("Selected columns: %s", text_df.select("id", "word"))
Modifier et exécuter le code