Skip to content

Instantly share code, notes, and snippets.

@danielfsilva88
Last active April 2, 2024 21:09
Show Gist options
  • Save danielfsilva88/ebd0e6ab6daab378fde2efbaaf80bbb5 to your computer and use it in GitHub Desktop.
Save danielfsilva88/ebd0e6ab6daab378fde2efbaaf80bbb5 to your computer and use it in GitHub Desktop.
Databricks general content

Databricks Content

Table of Contents

  1. Mount an external File System into Databricks File System
  2. Clear Cluster memory

1. Mount an external File System into Databricks File System

  1. References:
  1. Example to mount:
dbutils.fs.mount(
  source = "wasbs://<container-name>@<storage-account-name>.blob.core.windows.net",
  mount_point = "/mnt/<mount-name>",
  extra_configs = {"<conf-key>":dbutils.secrets.get(scope = "<scope-name>", key = "<key-name>")})

spark.conf.set(
  "fs.azure.sas.<container-name>.<storage-account-name>.blob.core.windows.net",
  "<complete-query-string-of-sas-for-the-container>")
  1. Example to unmount:
dbutils.fs.unmount("/mnt/<mount-name>")

2. Clear Cluster memory

  1. Clear Python memory:
import gc
gc.collect()
  1. Clear Cluster cache:
sqlContext.clearCache()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment