Sitemap
Cloud Wizards

Your go to source for mastering the art of cloud computing, artificial intelligence, machine learning, and data science. Deep Drive into the latest trends to build innovative and scalable solutions. Our articles and expert insights will guide you on your journey to be true wizard

Member-only story

Databricks Notebook Magic Commands: Beyond %sql and %python

--

The built-in commands everyone should know, the IPython extras worth trying, and the Databricks utilities that fill the gaps.

Press enter or click to view image in full size

Most people working with Databricks notebooks learn %sql, %python, and %run during their first week and rarely look beyond them. But notebook cells can do more than run SQL queries or Python scripts. With a few extra commands, you can time code, capture output, run shell commands, inspect variables, and look up documentation without leaving the notebook.

This guide covers two groups of commands, and the distinction is important when something doesn’t work as expected. The first group consists of documented Databricks features. The second consists of IPython magics inherited from the notebook’s underlying Python environment.

Both can be useful, but they aren’t interchangeable. IPython magic commands may behave differently depending on your Databricks Runtime version and compute type. Before relying on them in a shared workflow, test them on the cluster where you intend to use them.

1. How magic commands work

A magic command is a special instruction that starts with % and changes how a notebook cell behaves. It lets you do things that go beyond running ordinary code.

--

--

Manoj Saini
Manoj Saini

Written by Manoj Saini

Cloud Platform Engineer | DevOps & MLOps | AWS & GCP | Kubernetes (EKS/GKE) | Serverless | Terraform & IaC | Databricks & GenAI

Cloud Wizards
Cloud Wizards

Published in Cloud Wizards

Your go to source for mastering the art of cloud computing, artificial intelligence, machine learning, and data science. Deep Drive into the latest trends to build innovative and scalable solutions. Our articles and expert insights will guide you on your journey to be true wizard