如何使用 U-SQL 合并 N 天的文件

How to merge files for N number of days using U-SQL

我想合并 7 天文件的数据,并使用 U-SQL 对它们执行一些操作。 ADLS 上的文件夹结构 - /sample/data/YYYY/MM/DD.1.csv 例如今天是 03/01/2018 (DD/MM/YYYY) 那么我想选择 27/12/2017 到 02/01/2018 的数据。

在U-SQL如何实现?

您应该在文件路径中使用虚拟列。
例如:

 DECLARE @path = "/sample/data/{FileDate:yyyy}/{FileDate:MM}/{FileDate:dd}.1.csv
 DECLARE @startDate = new DateTime(2017,12,27);
 DECLARE @endDate = new DateTime(2018,01,02);

 @data = EXTRACT 
     column1 string,
    column2 string,
    FileDate DateTime
    from @path
USING Extractors.Csv(); //or which extractor you are using


OUTPUT(
SELECT * FROM @data
WHERE FileDate BETWEEN @startDate AND @endDate)
TO "/sample/data/appended.csv
USING Outputters.Text(delimiter : ';', outputHeader : true); //output this in your csv file

此代码应提取您日期范围内的所有数据。 P.S。我不确定我是否写了正确的文件名,请检查一下。 希望这会帮助你。 Here 您可以找到有关虚拟列的文档。