Forum Discussion
Query folding
- 1 year ago
How to verify your query is folded (Databricks + Value.NativeQuery):
-
Value.NativeQuery already sends SQL to Databricks. Folding only matters for steps after that step.
-
In Power Query, right-click the last step >> View Native Query.
-
Clickable = still folded to SQL.
-
Greyed out = folding broke earlier.
-
-
Do a quick litmus test: add Keep Top Rows >> 5 (or filter a date). Recheck View Native Query.
-
If you see LIMIT 5 (or your WHERE clause) in the SQL, it’s folded.
-
-
Cross-check in Databricks >> SQL >> Query History while preview/refresh runs.
-
Your server log should show the final SQL with your filters. If it shows SELECT * and filters aren’t there, they were applied locally.
-
-
Remember: many steps break folding (e.g., Table.Buffer, custom M, merges with non-foldable sources). Put them after you’ve narrowed data.
-
I filtered on top 5 rows it still grey
but when i searched for history query i found the query running in databricks
so what that mean view native query is grey but the query is running in databricks from query history
View Native Query being grey doesn’t mean folding is off. With Databricks, that button often stays disabled even when Power Query pushes your steps (like Top 5) down to the source. The fact you see the query in Databricks Query History means folding happened and Databricks executed it.
Quick ways to verify:
-
Turn on Query folding indicators (Power Query Options). Solid/striped icons = folded.
-
Make your filters/projections the first steps; refresh preview and watch Query History (you should see LIMIT 5/TOP 5).
-
If you add a non-foldable step later (e.g., Table.Buffer, some custom columns/merges), the button greys out even though earlier steps still folded.