auto_increment in U-SQL

孤街醉人 提交于 2019-12-11 02:12:42

问题


I am trying to form a new table that contains unique user_id's from existing one. Is it possible to add auto_increment primary key in U-SQL like we can add in MySQL?


回答1:


To elaborate on David's answer: Unlike MySQL, ADLA/U-SQL is executed in a scale-out shared nothing architecture. Thus there is not an easy way to manage auto-incremental numbers.

However, there is are some tricks that you can use:

  1. You can use the ROW_NUMBER() function to generate a number per row. You could add that to the MAX you have so far.
  2. Or you could use DateTime.Now.Ticks to get an initial seed (plus some additional offset if you want to make sure you do not have overlapping ranges between different inserts) and the use ROW_NUMBER().
  3. Less recommended is the use of NewGUID(), since that generates a different guid and is not repeatable. Thus if a vertex is retried, it may fail the job due to non-determinism.

I hope this helps.




回答2:


This is not currently possible.



来源:https://stackoverflow.com/questions/49038536/auto-increment-in-u-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!