Ćwiczenie logowania
Poniższy kod jest wykonywany przy uruchomieniu:
import logging
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG,
format='%(levelname)s - %(message)s')
Przećwiczysz teraz te operacje logowania.
To ćwiczenie jest częścią kursu
Wprowadzenie do Spark SQL w Pythonie
Instrukcje do ćwiczenia
- Zapisz kolumny
text_dfjako komunikat debug. - Zapisz informację o tym, czy
table1jest zbuforowana, jako komunikat info. - Zapisz pierwszy wiersz
text_dfjako komunikat warning. - Zapisz wybrane kolumny
text_dfjako komunikat error.
Interaktywne ćwiczenie praktyczne
Spróbuj tego ćwiczenia, uzupełniając ten przykładowy kod.
# 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"))