Union duplicates data?

I am experimenting with Union and I got confused by the results its yielding.
This is my FQL code:

Let(
      {
        h264: Match(Index("VideoUpload_preset_status"), ["h264", "DONE"]),
        h265: Match(Index("VideoUpload_preset_status"), ["h265", "DONE"]),
        vp9: Match(Index("VideoUpload_preset_status"), ["vp9", "DONE"])
      },
      Union(Var("h264"), Var("h265"), Var("vp9"))
    )

Which produces:

{
  "@set": {
    union: [
      {
        "@set": {
          match: Index("VideoUpload_preset_status"),
          terms: ["h264", "DONE"]
        }
      },
      {
        "@set": {
          match: Index("VideoUpload_preset_status"),
          terms: ["h265", "DONE"]
        }
      },
      {
        "@set": {
          match: Index("VideoUpload_preset_status"),
          terms: ["h265", "DONE"]
        }
      },
      {
        "@set": {
          match: Index("VideoUpload_preset_status"),
          terms: ["vp9", "DONE"]
        }
      }
    ]
  }
}

Please notice that h265 appears twice in the results. Why?
If I run the same code but without Union it returns an array with only 3 objects, as expected.

@zvictor Thanks for pointing this out. AFAIK, it is because Union internally works on two sets at a given time and a Paginate on Union seems to resolve these dups. I am working with the team to get specific details on this behavior, and it could be next week after the holidays.

1 Like