cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Is there a command in sql cell to ignore formatting for some lines like `# fmt: off` in Python cells

jonathan-dufaul
Valued Contributor

In python cells I can add the comments `# fmt: off` before a block of code that I want black/autoformatter to ignore and `# fmt: on` afterwards. Is there anything similar I can put in sql cells to accomplish the same effect?

Some of the recommendations make the code far less legible.

Also is there any way to ignore single lines in the python cell?

2 REPLIES 2

The sql formatter I'm using is whatever databricks notebooks in the workspace themselves are using (with Ctrl-Shift-F). Is that link related to databricks?

I'll accept since it looks like the answer is a no for an ignore command in sql cells.

I found out that you can ignore single lines in python cells by putting `# fmt: skip` at the end. There has to be a space between the `#` and fmt or else you'll get a "AssertionError: INTERNAL ERROR: Black produced different code on the second pass of the formatter. Please report a bug on https://github.com/psf/black/issues." error

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group