todatasubset() not returning the correct total count when batch size is 0

So I appended 2 List of Dictionaries in a local variable and then did a todatasubset() on this local variable with a batch size of -1 and the total count was correct. When I changed the batch size to 0, the total count returned 0 when I was expecting it to return the same total count as when I passed in -1 for the batch size. Any ideas on why this is happening or what I'm doing wrong?

  • Hey Jamal,

    My guess is this is a data related issue of some sort. The below code returns 4 regardless of whether the batch size is -1 or 0, so I think your case must be a bit different. Please post your code for us to have a better idea.

    todatasubset(
    append(
    {
    {id: 1, name: "A"},
    {id: 2, name: "B"}
    },
    {
    {id: 3, name: "C"},
    {id: 4, name: "D"}
    }
    ),
    a!pagingInfo(1, -1)
    ).totalCount

    todatasubset(
    append(
    {
    {id: 1, name: "A"},
    {id: 2, name: "B"}
    },
    {
    {id: 3, name: "C"},
    {id: 4, name: "D"}
    }
    ),
    a!pagingInfo(1, 0)
    ).totalCount
  • Hi there,

    Please run this code

    load(
    local!x1:{{id:1,name:"name1"},{id:2,name:"name2"}},
    local!x2:{{id:3,name:"name3"},{id:4,name:"name4"}},
    local!x3:append(local!x1,local!x2),
    local!ans1:todatasubset(local!x3,a!pagingInfo(startIndex: 1,batchSize: 0)),
    local!ans1
    )


    please change batchSize to 1,-1 2 ,4
    You will notice that totalCount remains same. That is 4.
    Let me know if this code helped you.

    Thanks!
    Mayur Mondhe
  • The batchsize is used to return the number of rows you wanted to get from the DB.

    If you change it to zero, that means, that you are getting zero records.

    Please post your code.

  • I had a similar issue while dealing with a view that was due to duplicates being present in the data. Because of the way the view was set up, it was possible for duplicate entries to occur.

    When used with the a!pagingInfo with a batchSize of -1, the query to the view always returned the correct count equal to what we had in the database. When we switched the batchSize with a value >= 0, we saw that the total count shrunk by a few values. Putting a DISTINCT on the view gave us the same count as what came back in that case so that's what led us to suspect it was because of duplicates. I think either the query of pagingInfo had some functionality that automatically removes duplicates that doesn't seem clear from the documentation.

    I would check if with the data you're using any of the values are duplicates and if the difference between the -1 and 0 batch sizes is the number of those duplicates.

 Discussion posts and replies are publicly visible