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.

Can you share your query? The table column is an auto-generated numeric column that denotes which table is returned. A table is a group of rows that all have the same group key. In general, the window() function creates a new group for each interval. My guess is you are running window(every: 5m) and getting a bunch of tables. The reason why window(every: inf) then undoes that is because it concatenates all of the points into the same window and therefore the same group.

I could know more if I saw the downsampling query though.