โ01-05-2024 02:10 PM
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?
โ01-07-2024 10:30 PM - edited โ01-09-2024 12:26 AM
Hi @jonathan-dufaul, Sorry to have misread your question.
In Databricks, the # fmt: off and # fmt: on comments are used to control the autoformatter in Python cells. However, based on my search, there doesnโt seem to be a similar command to ignore formatting in SQL ....
As for ignoring single lines in a Databricks Python cell, there isnโt a specific command to ignore a single line. The # fmt: off and # fmt: on comments apply to the entire block of code between them. If you want to prevent formatting on a specific line, you might consider isolating it in its own # fmt: off and # fmt: on block.
โ01-07-2024 10:30 PM - edited โ01-09-2024 12:26 AM
Hi @jonathan-dufaul, Sorry to have misread your question.
In Databricks, the # fmt: off and # fmt: on comments are used to control the autoformatter in Python cells. However, based on my search, there doesnโt seem to be a similar command to ignore formatting in SQL ....
As for ignoring single lines in a Databricks Python cell, there isnโt a specific command to ignore a single line. The # fmt: off and # fmt: on comments apply to the entire block of code between them. If you want to prevent formatting on a specific line, you might consider isolating it in its own # fmt: off and # fmt: on block.
โ01-08-2024 07:05 AM
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?
โ01-22-2024 06:28 AM
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
โ01-18-2024 02:52 AM
Thank you for posting your question in our community! We are happy to assist you.
To help us provide you with the most accurate information, could you please take a moment to review the responses and select the one that best answers your question?
This will also help other community members who may have similar questions in the future. Thank you for your participation and let us know if you need any further assistance!
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