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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Ben-Dev
Helper II
Helper II

Table.Combine Dies With Stack Overflow

Hello Microsoft Team,

 

I've stumbled across a stack overflow error which rears its ugly head if I try to Table.Combine two tables which are both based on Table.View. 😞

 

Any idea what's going on here, or suggestions on how we can prevent this? Is this a Power Query bug?

 

Cutting it down to the relevant code, here's a repo example which can be demoed in Power BI's Query Editor:

let
    GetView = (state as record) => 
        Table.View(
            null,
            [
                GetType = () => Value.Type(GetRows()),
                GetRows = () => #table({"Col1"}, {{"a"}}),
                OnTake = (count as number) => @GetView(state & [Take = count])
            ]
        )
    ,
    Table = GetView([])
in
    // * The following successfully return a table:
    // Table
    // Table.FirstN(Table, 1000)

    // * All of the following die with: 'Expression.Error: Evaluation resulted in a stack overflow and cannot continue.'
    // Table.FirstN(Table.Combine({Table, Table}), 1000)
    // Table.Combine({Table.FirstN(Table, 1000), Table.FirstN(Table, 1000)})
    Table.Combine({Table, Table})

 

The self-reference (i.e. the above combining Table with itself) doesn't appear to be the issue, as the stack overflow also occurs when two different views are involved:

let
    GetViewA = (state as record) => 
        Table.View(
            null,
            [
                GetType = () => Value.Type(GetRows()),
                GetRows = () => #table({"Col1"}, {{"a"}}),
                OnTake = (count as number) => @GetViewA(state & [Take = count])
            ]
        )
    ,
    GetViewB = (state as record) => 
        Table.View(
            null,
            [
                GetType = () => Value.Type(GetRows()),
                GetRows = () => #table({"Col1"}, {{"a"}}),
                OnTake = (count as number) => @GetViewB(state & [Take = count])
            ]
        )
in
    Table.Combine({GetViewA([]), GetViewB([])})

 

Help here would be much appreciated! Thank you!

4 REPLIES 4
v-jingzhang
Community Support
Community Support

Hi @Ben-Dev 

 

I tested with a simple Table view. It can be combined with itself. 

vjingzhang_0-1653980065243.png

vjingzhang_1-1653980471533.png

Perhaps the issue is due to the code for generating your table view?  

 

Best Regards,
Community Support Team _ Jing

Thanks, @v-jingzhang!

 

I believe the issue here may be related to the combination of Table.Combine and OnTake. From what I'm hearing, sounds like there's an underlying issue which I'll just have to live with.

AlexisOlson
Super User
Super User

I don't know if this helps whatever your ultimate goal is but you can avoid the error by buffering Table to memory.

 

That is, replace 

Table = GetView([])

 with

Table = Table.Buffer(GetView([]))

Hi @AlexisOlson, thanks!

 

Unfortunatley, since buffering blocks subsiquent folding and the real-life Table.View handles more complex folding than is shown in the example, I'm not sure I can realistically use buffering. 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.