'Why compute row_number() order by monotonically_increasing_id() in Spark?

It is suggested that you can 'generate unique increasing numeric values' by

select row_number() over (order by monotonically_increasing_id()) from /* ... */

But you can just as well do this:

select row_number() over (order by 1) from /* ... */

What benefit does using monotonically_increasing_id() provide in this case?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source