Forum Discussion

WILLIAM_AFFONSO's avatar
WILLIAM_AFFONSO
Frequent Visitor
1 year ago
Solved

How to run custom SQL queries in Azure Databricks without using ODBC in Power BI?

Hi everyone, I'm using the native Azure Databricks connector in Power BI with this setup: Databricks.Catalogs("adb-xxxx.azuredatabricks.net", "/sql/1.0/warehouses/xxxx", [Catalog = "dtXXXX", Data...
  • WILLIAM_AFFONSO's avatar
    1 year ago

    Hi everyone, thank you all for your contributions!

    I wanted to share that I was able to solve the issue on my own. I had already read the documentation several times (including the official blog post), but I couldn’t get it to work in my specific context — especially through a script-based setup in Power Query.

    In the end, I found a solution that worked by applying a native SQL query using this structure:

    Fonte = Value.NativeQuery(
    Databricks.Catalogs(
    "adb-xxxx.azuredatabricks.net",
    "/sql/1.0/warehouses/xxxx",
    [Catalog = "dtXXXX", Database = null, EnableAutomaticProxyDiscovery = "enabled"]
    ){[Name="dtXXXX", Kind="Database"]}[Data],
    "
    SELECT * FROM your_table
    WHERE my_column IS NOT NULL
    "
    )

    This allowed me to run the SQL script directly without needing to rely on ODBC or predefined views.

    I’ll go ahead and mark the thread as resolved — though I won’t select any specific reply, since I was looking specifically for a script-based solution that I ended up crafting myself.

    Thanks again to everyone who contributed!