How can I fix strange magic command behaviour in Databricks notebooks?

Joseph Sharman 1 Reputation point
2022-10-03T13:16:00.433+00:00

Hi,

I have encountered a strange issue when using magic commands on my Azure Databricks workspace.

When I create a cell and type the magic command for a language which is not default in the notebook, the code is instead interpreted as the default notebook language.

Here you can see a notebook with python as the default language, with a sql magic command:

247077-magic-command-manually-typed.png

And here, the same notebook. But with python code written in the cell.
247009-magic-command-manually-typed-2.png

However, if I create a cell at the end of the notebook (not in between existing cells). And then set the language to SQL using this button, the code will be correctly interpreted as SQL.
247053-renditiondownload.jpg
This issue first arose this week on Monday the 26th of September. It has broken a lot of my existing notebooks which use "%sql".

I have tried restarting my cluster, creating a new cluster, creating a new notebook, and changing my notebook default language. But none of these have fixed the issue.

Thanks,
Joe

Edit:
This is the Log4j output when I try and run a %sql cell when I have typed "%sql" rather than using the UI to select sql.
"ERROR WSFSDriverManager$: Files only supported within a repository. Invalid base notebook path: /Users/{email}/{folder}{notebook}"

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,514 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Joseph Sharman 1 Reputation point
    2022-10-04T10:02:11.87+00:00

    Hi @SSingh-MSFT

    Thanks for your reply!

    That output you have is what I had previously (before I started having issues).

    I believe the notebook in in workspace, not DBFS. I wasn't entirely sure how to check, but from this I believe it is in Workspace?

    247381-image.png

    Thanks,
    Joe


  2. Joseph Sharman 1 Reputation point
    2022-10-04T13:57:20.373+00:00

    Hi,

    I don't have Git repositories linked to Databricks, and I have not had one set up in the past.

    Therefore I think none of these points are an issue.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.