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.
Este exercício faz parte do curso
Introduction to Spark SQL in Python
Instruções do exercício
- Log columns of
text_dfas debug message. - Log whether
table1is cached as info message. - Log first row of
text_dfas warning message. - Log selected columns of
text_dfas error message.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# 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"))