Member-only story

Gaurav Gurjar
Jan 8, 2024

Magics in Notebooks

Magic #1 Info

Example: ``%%info```

This one outputs session information from Livy.

Magic #2 cleanup

Example: ``%%cleanup -f``

This one deletes all sessions running on the current Livy endpoint. The ``f`` switch forces the cleanup.

Magic #3 delete

Example: ``delete -f -s 0``

This one deletes the session specified the ``-s`` switch; the ``-f`` switch forces the deletion.

Magic #4 configure

Example: ``%%configure -f {“executorMemory”: “100M”, “executorCores”:4}``

This one arguably the most useful magic. Allows you to figure your session.

Magic #4 ``sql``

Example: ``%%sql -o tables -q SHOW TABLES``

This one executes an SQL query against the current spark session.

Magic #5 ``local``

Example: ``%%local a=1``

This one magic does all the code in the Notebook cell with this magic will be executed locally against the Python environment.

Let me know what else magic commands you know.

Gaurav Gurjar
Gaurav Gurjar

Written by Gaurav Gurjar

I share compassion with people, data and business intelligence. Contributed to data products worth of $2M-$20M, Wrangled data size of 10KB-20PB

No responses yet