Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Hoping
Helper III
Helper III

Query Folding in Databricks - Left join vs Merge Queries

I am connecting to Databricks through Native Query that uses left joins and has where clause.

 

Based on the Microsodt Document - Optimize by Expanding Columns  it seems that merge queries are better than using left joins.

 

Also based on the article on Query folding in Azure Databricks it is suggested that Dtabricks.Query be used instead of the Databricks.Catalog connector that does not allow query folding. Additionaly, it is suggested that teh WHERE clause be separated out.

 

Based on the above:

 

1.  Are merge queries better than left joins used in native SQL queries? Why so?  When the technique mentioned in the article was used, I could see that "View Native Query" option was enabled i.e not greyed out meaning query folding was happening. Wouldn't the entire query including the joins and where clauses get executed at the source -Databricks?

 

2. According to the article, its better to split the query into 2 parts - WHERE clause separately and also parametarise the query if possible. What advantage does this bring (if any)?  My query still folds with just one long query including the WHERE clause.

 

3. What about the Databricks.Catalogs is not allowing query folding to happen ? Even when Enable query folding was set to "TRUE", the option to view native query was disabled as shown below:

Value.NativeQuery(Databricks.Catalogs(host_path, warehouse_path)[Catalog="hive_metastore", Database=null, EnableAutomaticProxyDiscovery=null]) {[Name="hive_metastore",Kind="Database"]}[Data], "select * from schema.table A left join another_table B on A.key_col = B.key_col where B.key_col = "some_value"", null, [EnableFolding=true])


Which is a preferable way to optimise for efficiency?

 

1. Import separate tables and the merge them into one ?

2. Use Databricks.Query and use a SQL with left join and seperate out the where clause ?

1 REPLY 1
Anonymous
Not applicable

@Hoping did you ever fix this? running into the same issues now with query folding and databricks. Whatever I try, it doesn't work even though databricks itself explicitly mention that query folding should be possible now:

https://www.databricks.com/blog/databricks-power-bi-connector-now-supports-native-query 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.