how do we generate a random id for each record?

时光毁灭记忆、已成空白 提交于 2019-12-11 15:08:37

问题


How do we generate a separate file for every record, containing a unique name?

I would like every row in my dataset to have a unique identifier, a guid preferably, but it could be anything:

@file =
    EXTRACT col1 string,
            col2 string,
            col3 string
    FROM @file1
    USING Extractors.Csv(silent : true);


@output =
    SELECT *, Guid.NewGuid().ToString() AS [myId]
    FROM @file;

I would then create a separate file for each record:

OUTPUT @output
TO "/myFirstFunction_{myId}.txt"
USING Outputters.Tsv();

The files would be something like:

myFirstFunction_ba07d61d-a748-4344-bf70-da0012bd28bc.txt
myFirstFunction_36d9c255-eb0b-418d-adfe-a8bf2648ae57.txt
myFirstFunction_7858b8fc-7920-4918-bfcc-6b308d141d57.txt
myFirstFunction_9501ad01-73b8-43cb-be09-3bed4ebc8b7c.txt
myFirstFunction_59e10991-b431-4fb2-a165-5c9467f08ddd.txt
..

How do we generate a separate file for every record, containing a unique name?

来源:https://stackoverflow.com/questions/57977315/how-do-we-generate-a-random-id-for-each-record

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