Easiest/efficient way to add monotonically increasing row number in Pipeline Builder?

hello community! I am posting a common need in pipelining regarding adding a rownum column that contains monotonically increasing integers (presumably based off a sorted window or otherwise).

The sequence function almost works here if you pass it dataset_row_count, but sadly that makes an array of al the numbers that need to be applied individually per row (the array needs to be unpacked or mapped to our target rownum column). I also tried Window and lag but dont have a way to grab a non constant number larger by 1 each time with that approach (so the column ends up being all e.g. 1’s or 2’s).

Please let me know if there is an easy way to do this without custom functions :slight_smile:

Hey @fguze you should be able to do with with a sorted window (partitioned by any column) and using the Row number expression

2 Likes