Enable PySpark and Databricks Utilities code completion for the Databricks extension for Visual Studio Code

This article describes how to enable PySpark and Databricks Utilities code completion for the Databricks extension for Visual Studio Code. See What is the Databricks extension for Visual Studio Code?

This information assumes that you have already installed and set up the Databricks extension for Visual Studio Code. See Install the Databricks extension for Visual Studio Code.

To enable IntelliSense (also known as code completion) in the Visual Studio Code code editor for PySpark, Databricks Utilities, and related globals such as spark and dbutils, do the following with your code project opened:

  1. On the Command Palette (View > Command Palette), type >Databricks: Configure autocomplete for Databricks globals and press Enter.

  2. Follow the on-screen prompts to allow the Databricks extension for Visual Studio Code to install PySpark for your project, and to add or modify the __builtins__.pyi file for your project to enable Databricks Utilities.

You can now use globals such as spark and dbutils in your code without declaring any related import statements beforehand.