|
23 | 23 | # MAGIC
|
24 | 24 | # MAGIC
|
25 | 25 | # MAGIC ##### Databricks Notebook Utilities
|
26 |
| -# MAGIC - <a href="https://docs.databricks.com/notebooks/notebooks-use.html#language-magic" target="_blank">Magic commands</a>: `%python`, `%scala`, `%sql`, `%r`, `%sh`, `%md` |
27 |
| -# MAGIC - <a href="https://docs.databricks.com/dev-tools/databricks-utils.html" target="_blank">DBUtils</a>: `dbutils.fs` (`%fs`), `dbutils.notebooks` (`%run`), `dbutils.widgets` |
28 |
| -# MAGIC - <a href="https://docs.databricks.com/notebooks/visualizations/index.html" target="_blank">Visualization</a>: `display`, `displayHTML` |
| 26 | +# MAGIC - <a href="https://docs.databricks.com/notebooks/notebooks-use.html#language-magic" target="_blank">Magic commands</a>: **`%python`**, **`%scala`**, **`%sql`**, **`%r`**, **`%sh`**, **`%md`** |
| 27 | +# MAGIC - <a href="https://docs.databricks.com/dev-tools/databricks-utils.html" target="_blank">DBUtils</a>: **`dbutils.fs`** **(`%fs`)**, **`dbutils.notebooks`** **(`%run`)**, **`dbutils.widgets`** |
| 28 | +# MAGIC - <a href="https://docs.databricks.com/notebooks/visualizations/index.html" target="_blank">Visualization</a>: **`display`**, **`displayHTML`** |
29 | 29 |
|
30 | 30 | # COMMAND ----------
|
31 | 31 |
|
32 | 32 | # MAGIC %md ### Setup
|
33 | 33 | # MAGIC Run classroom setup to mount Databricks training datasets and create your own database for BedBricks.
|
34 | 34 | # MAGIC
|
35 |
| -# MAGIC Use the `%run` magic command to run another notebook within a notebook |
| 35 | +# MAGIC Use the **`%run`** magic command to run another notebook within a notebook |
36 | 36 |
|
37 | 37 | # COMMAND ----------
|
38 | 38 |
|
|
49 | 49 |
|
50 | 50 | # COMMAND ----------
|
51 | 51 |
|
52 |
| -# MAGIC %md Run language specified by language magic commands: `%python`, `%scala`, `%sql`, `%r` |
| 52 | +# MAGIC %md Run language specified by language magic commands: **`%python`**, **`%scala`**, **`%sql`**, **`%r`** |
53 | 53 |
|
54 | 54 | # COMMAND ----------
|
55 | 55 |
|
|
73 | 73 |
|
74 | 74 | # COMMAND ----------
|
75 | 75 |
|
76 |
| -# MAGIC %md Run shell commands on the driver using the magic command: `%sh` |
| 76 | +# MAGIC %md Run shell commands on the driver using the magic command: **`%sh`** |
77 | 77 |
|
78 | 78 | # COMMAND ----------
|
79 | 79 |
|
80 | 80 | # MAGIC %sh ps | grep 'java'
|
81 | 81 |
|
82 | 82 | # COMMAND ----------
|
83 | 83 |
|
84 |
| -# MAGIC %md Render HTML using the function: `displayHTML` (available in Python, Scala, and R) |
| 84 | +# MAGIC %md Render HTML using the function: **`displayHTML`** (available in Python, Scala, and R) |
85 | 85 |
|
86 | 86 | # COMMAND ----------
|
87 | 87 |
|
|
92 | 92 |
|
93 | 93 | # MAGIC %md
|
94 | 94 | # MAGIC ## Create documentation cells
|
95 |
| -# MAGIC Render cell as <a href="https://www.markdownguide.org/cheat-sheet/" target="_blank">Markdown</a> using the magic command: `%md` |
| 95 | +# MAGIC Render cell as <a href="https://www.markdownguide.org/cheat-sheet/" target="_blank">Markdown</a> using the magic command: **`%md`** |
96 | 96 | # MAGIC
|
97 |
| -# MAGIC Below are some examples of how you can use Markdown to format documentation. Click this cell and press `Enter` to view the underlying Markdown syntax. |
| 97 | +# MAGIC Below are some examples of how you can use Markdown to format documentation. Click this cell and press **`Enter`** to view the underlying Markdown syntax. |
98 | 98 | # MAGIC
|
99 | 99 | # MAGIC
|
100 | 100 | # MAGIC # Heading 1
|
|
141 | 141 | # MAGIC %md ## Access DBFS (Databricks File System)
|
142 | 142 | # MAGIC The <a href="https://docs.databricks.com/data/databricks-file-system.html" target="_blank">Databricks File System</a> (DBFS) is a virtual file system that allows you to treat cloud object storage as though it were local files and directories on the cluster.
|
143 | 143 | # MAGIC
|
144 |
| -# MAGIC Run file system commands on DBFS using the magic command: `%fs` |
| 144 | +# MAGIC Run file system commands on DBFS using the magic command: **`%fs`** |
145 | 145 |
|
146 | 146 | # COMMAND ----------
|
147 | 147 |
|
|
161 | 161 |
|
162 | 162 | # COMMAND ----------
|
163 | 163 |
|
164 |
| -# MAGIC %md `%fs` is shorthand for the <a href="https://docs.databricks.com/dev-tools/databricks-utils.html" target="_blank">DBUtils</a> module: `dbutils.fs` |
| 164 | +# MAGIC %md `%fs` is shorthand for the <a href="https://docs.databricks.com/dev-tools/databricks-utils.html" target="_blank">DBUtils</a> module: **`dbutils.fs`** |
165 | 165 |
|
166 | 166 | # COMMAND ----------
|
167 | 167 |
|
|
195 | 195 |
|
196 | 196 | # COMMAND ----------
|
197 | 197 |
|
198 |
| -files = dbutils.fs.ls(eventsPath) |
| 198 | +files = dbutils.fs.ls(events_path) |
199 | 199 | display(files)
|
200 | 200 |
|
201 | 201 | # COMMAND ----------
|
|
209 | 209 |
|
210 | 210 | # COMMAND ----------
|
211 | 211 |
|
212 |
| -spark.sql(f"SET c.events_path = {eventsPath}") |
| 212 | +spark.sql(f"SET c.events_path = {events_path}") |
213 | 213 |
|
214 | 214 | # COMMAND ----------
|
215 | 215 |
|
216 | 216 | # MAGIC %md ## Create table
|
217 |
| -# MAGIC Run <a href="https://docs.databricks.com/spark/latest/spark-sql/language-manual/index.html#sql-reference" target="_blank">Databricks SQL Commands</a> to create a table named `events` using BedBricks event files on DBFS. |
| 217 | +# MAGIC Run <a href="https://docs.databricks.com/spark/latest/spark-sql/language-manual/index.html#sql-reference" target="_blank">Databricks SQL Commands</a> to create a table named **`events`** using BedBricks event files on DBFS. |
218 | 218 |
|
219 | 219 | # COMMAND ----------
|
220 | 220 |
|
|
227 | 227 |
|
228 | 228 | # COMMAND ----------
|
229 | 229 |
|
230 |
| -print(databaseName) |
| 230 | +print(database_name) |
231 | 231 |
|
232 | 232 | # COMMAND ----------
|
233 | 233 |
|
|
236 | 236 | # COMMAND ----------
|
237 | 237 |
|
238 | 238 | # MAGIC %md ## Query table and plot results
|
239 |
| -# MAGIC Use SQL to query the `events` table |
| 239 | +# MAGIC Use SQL to query the **`events`** table |
240 | 240 |
|
241 | 241 | # COMMAND ----------
|
242 | 242 |
|
|
268 | 268 |
|
269 | 269 | # COMMAND ----------
|
270 | 270 |
|
271 |
| -# MAGIC %md Access the current value of the widget using the function `getArgument` |
| 271 | +# MAGIC %md Access the current value of the widget using the function **`getArgument`** |
272 | 272 |
|
273 | 273 | # COMMAND ----------
|
274 | 274 |
|
|
288 | 288 |
|
289 | 289 | # COMMAND ----------
|
290 | 290 |
|
291 |
| -# MAGIC %md To create widgets in Python, Scala, and R, use the DBUtils module: `dbutils.widgets` |
| 291 | +# MAGIC %md To create widgets in Python, Scala, and R, use the DBUtils module: **`dbutils.widgets`** |
292 | 292 |
|
293 | 293 | # COMMAND ----------
|
294 | 294 |
|
|
297 | 297 |
|
298 | 298 | # COMMAND ----------
|
299 | 299 |
|
300 |
| -# MAGIC %md Access the current value of the widget using the `dbutils.widgets` function `get` |
| 300 | +# MAGIC %md Access the current value of the widget using the **`dbutils.widgets`** function **`get`** |
301 | 301 |
|
302 | 302 | # COMMAND ----------
|
303 | 303 |
|
|
0 commit comments