How to set up autocomplete for Databricks notebooks

Viewed 5684

How to enable code auto-completion feature for Databricks notebooks?
I'd like to have drop-down lists with available methods for objects, hints, variable names auto-completion, etc, at least for Scala & Spark notebooks in Databricks.

They claim to have autocomplete feature since 2015: https://forums.databricks.com/questions/784/is-there-autocomplete-for-name-completion-tooltip.html.
and some server autocomplete:
https://docs.databricks.com/release-notes/product/2018/april.html.

For me none of it works out-of-the-box, and I can't find a way how to enable it in settings.

But still it doesn't come even close to what is available in IntelliJ https://www.jetbrains.com/help/idea/auto-completing-code.html Are there some plugins to or language-server APIs for that?

Example:

val df = spark.read.schema(header).json(fileName)

df.repartition(1)
     .write
     .mode("overwrite")
     .option("path", "/.../my_df")
     .partitionBy("date")
     .save()

This is really upsetting, having to print all of this by hand just to read and write the dataframe.

2 Answers

Auto-complete should be enabled in your notebook, but it must be connected to a cluster, and you will need to execute all cells that contain objects for which you are looking to have auto-complete work. (https://docs.databricks.com/release-notes/product/2018/april.html#command-autocomplete)

To view the available methods, variables, etc. on an object, type the name of the object followed by a period ".", and then press the tab key. It doesn't work like IntelliJ or other IDEs, so you have to press tab to display the list.

When you have the required packages and framworks in place it intellij will automatically auto complete your code and provide you suggesstions if you are using sbt please wait until the required packages are loaded so as to start autocompleting the code if none of them works for you then

Refer here - Code completion intellij

Related