Skip to content

Databricks: Support for single-line magics #6998

@phant0mw0lf

Description

@phant0mw0lf

Search before asking

  • I searched the issues and found no similar issues.

What Happened

Sqlfluff does not correctly parse Databricks single-line magics (e.g., -- MAGIC %run ./Notebook). These lines are not recognized as valid magics, leading to parsing errors or the magics being treated as standard comments or code.

related to:
#6222
#6418

Expected Behaviour

  • Sqlfluff should recognize and correctly parse single-line magics in Databricks SQL files.
  • Single-line magics should be treated as special segments, not as standard comments or code.

Observed Behaviour

When running sqlfluff on a Databricks SQL file containing single-line magics, those lines are not parsed as magics, which can cause parsing errors or incorrect linting.

How to reproduce

valid notebook, but not parsable:

-- Databricks notebook source
-- MAGIC %md
-- MAGIC # MarkDown Cell

-- COMMAND ----------

-- MAGIC %run ./Notebook

-- COMMAND ----------

SELECT a FROM b

Dialect

databricks

Version

3.4.1

Configuration

sqlfluff lint test.sql --dialect databricks --templater raw

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions