लॉगिंग का अभ्यास
स्टार्टअप पर निम्न कोड चलाया जाता है:
import logging
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG,
format='%(levelname)s - %(message)s')
अब आप इन लॉगिंग ऑपरेशंस का अभ्यास करेंगे।
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Spark SQL परिचय
अभ्यास निर्देश
text_dfके कॉलम्स को debug मैसेज के रूप में लॉग करें.- यह लॉग करें कि
table1cache है या नहीं, info मैसेज के रूप में. text_dfकी पहली row को warning मैसेज के रूप में लॉग करें.text_dfके चुने हुए कॉलम्स को error मैसेज के रूप में लॉग करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# 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"))