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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply

Query Folding - Snowflake

Hi,

 

I am trying to investigate what folds and whats doesnt with this connection, and I noticed something I havent seen before.

When doing some simple filtering I can see in Snowflake query history that is folds, and I also see some simple transformation that doesnt fold. However, even if I put some transformation that doest fold BEFORE some simple filtering, I noticed that it still manages to fold the filter part....even though it comes after steps that does not fold.

 

Anyone else come across this and can share some info and/or links to documentation?

 

Regards,

Anders

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi Anders,

 

When Power Query creates the native query it evaluates your query in totality and optimises it as a whole. This means, for example, that you can add a complex logic column that doesn't fold, then remove some other columns (an operation that does fold) afterwards. If your complex logic column uses data from the columns that you didn't remove in the second step then PQ will optimise this query by removing the columns first, then adding the complex column afterwards.

Similarly, if you remove your complex logic column later in your query without having used its result, when PQ evaluates the query as a whole it won't even write the creation of the column in, as it can see it's not used or retained, thus allowing the query to fold in the backend even though it may display in the step list as unfoldable.

 

It's always good practice to put your foldable steps first for logic and clarity, but PQ will re-evaluate and optimise the query as a whole anyway.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

1 REPLY 1
BA_Pete
Super User
Super User

Hi Anders,

 

When Power Query creates the native query it evaluates your query in totality and optimises it as a whole. This means, for example, that you can add a complex logic column that doesn't fold, then remove some other columns (an operation that does fold) afterwards. If your complex logic column uses data from the columns that you didn't remove in the second step then PQ will optimise this query by removing the columns first, then adding the complex column afterwards.

Similarly, if you remove your complex logic column later in your query without having used its result, when PQ evaluates the query as a whole it won't even write the creation of the column in, as it can see it's not used or retained, thus allowing the query to fold in the backend even though it may display in the step list as unfoldable.

 

It's always good practice to put your foldable steps first for logic and clarity, but PQ will re-evaluate and optimise the query as a whole anyway.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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