我们知道在提取文件时U-SQL支持目录和文件名模式匹配。我想知道它是否支持基于ADLS中文件创建日期的模式匹配(无需实现自定义提取器)。U-SQL是否支持根据ADLS中的创建日期提取文件
说一个文件夹包含跨月创建的文件(文件名没有日期作为文件名的一部分),是否有办法只拉一个月的文件。
我们知道在提取文件时U-SQL支持目录和文件名模式匹配。我想知道它是否支持基于ADLS中文件创建日期的模式匹配(无需实现自定义提取器)。U-SQL是否支持根据ADLS中的创建日期提取文件
说一个文件夹包含跨月创建的文件(文件名没有日期作为文件名的一部分),是否有办法只拉一个月的文件。
U-SQL EXTRACT操作符不知道有关文件的任何元数据(如创建日期) - 只有文件名。
目前无法访问或使用文件元数据属性。请将您的投票和用例添加到以下反馈项目中:https://feedback.azure.com/forums/327234-data-lake/suggestions/10948392-support-functionality-to-handle-file-properties-fr
您可以使用.NET SDK构建解决方案。对于相当简单的事情,您可以使用PowerShell创建一个文件,其中将包含符合日期时间标准的所有文件。然后根据需要消费内容。
# Log in to your Azure account
Login-AzureRmAccount
# Modify variables as required
$DataLakeStoreAccount = "<yourDataLakeStoreAccountNameHere>";
$DataLakeAnalyticsAccount = <yourDataLakeAnalyticsAccountNameHere>";
$DataLakeStorePath = "/Samples/Data/AmbulanceData/"; #modify as desired
$outputFile = "Samples/Outputs/ReferenceGuide/filteredFiles.csv"; #modify as desired
$filterDate = "2016-11-22";
$jobName = "GetFiles";
# Query directory and build main body of script. Note, there is a csv filter.
[string]$body =
"@initial =
SELECT * FROM
(VALUES
" +
(Get-AzureRmDataLakeStoreChildItem -Account $DataLakeStoreAccount -Path $DataLakeStorePath |
Where {$_.Name -like "*.csv" -and $_.Type -eq "FILE"} | foreach {
"(""" + $DataLakeStorePath + $_.Name + """, (DateTime)FILE.CREATED(""" + $DataLakeStorePath + $_.Name + """)), `r`n" });
# formattig, add column names
$body =
$body.Substring(0,$body.Length-4) + "
) AS T(fileName, createDate);";
# U-SQL query and OUTPUT statement
[string]$output =
"
// filter results based on desired time frame
@filtered =
SELECT fileName
FROM @initial
WHERE createDate.ToString(""yyyy-MM-dd"") == ""$filterDate"";
OUTPUT @filtered
TO ""$outputFile""
USING Outputters.Csv();";
# bring it all together
$script = $body + $output;
#Execute job
$jobInfo = Submit-AzureRmDataLakeAnalyticsJob -Account $DataLakeAnalyticsAccount -Name $jobName -Script $script -DegreeOfParallelism 1
#check job progress
Get-AzureRmDataLakeAnalyticsJob -Account $DataLakeAnalyticsAccount -JobId $jobInfo.JobId -ErrorAction SilentlyContinue;
Write-Host "You now have a list of desired files to check @ " $outputFile