我想在U-SQL中创建一列数字或键,它们返回相同数量的相等行,以用作Extension.R.Reducer上的分区。 例如,如果我将变量用作:
INTERVAL '1-10' YEAR TO SECOND
INTERVAL '20:03:15' DAY TO SECOND
INTERVAL '1' DAY
我想获得一些东西作为“分区”列的此示例:
有什么主意吗?预先感谢!
答案 0 :(得分:1)
您可以调整此脚本以执行所需的操作。 这将分为3个分区:
@aLog =
SELECT * FROM
( VALUES
("ABC", new DateTime(2017,01,01, 05, 00, 00), new DateTime(2017,01,01, 06, 00, 00)),
("XYZ", new DateTime(2017,01,01, 05, 00, 00), new DateTime(2017,01,01, 06, 00, 00)),
("ABC", new DateTime(2017,01,01, 08, 00, 00), new DateTime(2017,01,01, 09, 00, 00)),
("ABC", new DateTime(2017,01,01, 08, 00, 00), new DateTime(2017,01,01, 10, 00, 00)),
("ABC", new DateTime(2017,01,01, 10, 00, 00), new DateTime(2017,01,01, 14, 00, 00)),
("ABC", new DateTime(2017,01,01, 07, 00, 00), new DateTime(2017,01,01, 11, 00, 00)),
("ABC", new DateTime(2017,01,01, 09, 00, 00), new DateTime(2017,01,01, 11, 00, 00)),
("ABC", new DateTime(2017,01,01, 11, 00, 00), new DateTime(2017,01,01, 11, 30, 00)),
("FOO", new DateTime(2017,01,01, 23, 40, 00), new DateTime(2017,01,01, 23, 59, 00)),
("FOO", new DateTime(2017,01,01, 23, 50, 00), new DateTime(2017,01,02, 00, 40, 00))
) AS T(user, begin, end);
@aLog =
SELECT (ROW_NUMBER() OVER() -1) / 3 AS Partition,
*
FROM @aLog;
OUTPUT
@aLog
TO "/teste.txt"
USING Outputters.Csv();