Values in column 'table' behave differently in query result compared to using it after insert into bucket

I have implemented a task in Influxdb v2 which downsamples data. It retrieves data from bucket 1 and stores it downsampled per day into bucket 2.
What I see is when I run my query in the script editor, that the value in column ‘table’ has the value 0 (ie after a |> window(every : inf). Then I place this script in my task and make sure it will be inserted into bucket 2. After running the task and looking at the result, I see that every row in my result from bucket 2, the column ‘table’ has a different number. This doesn’t look consistent compared to just running the query directly on bucket 1.

What is the reason for this? I don’t want to fix/change this behaviour by addin ‘|> window(every : inf)’ to my queries running on downsampled data.