使用输出器

时间:2016-06-13 10:26:11

标签: azure-data-lake u-sql

在u-sql查询中,通过Outputterss.Csv()函数将数据从一个csv文件转储到另一个csv文件,但是带有列名的标题行出现在文件末尾而不是顶部。请在下面找到我的代码。谢谢你的帮助

@telDataResult=


SELECT 
"vin" AS vin,
"outsideTemperature" AS outsideTemperature,
"EventProcessedUtcTime" AS EventProcessedUtcTime,
"PartitionId" AS PartitionId,
"EventEnqueuedUtcTime" AS EventEnqueuedUtcTime,
"IoTHub" AS IoTHub

FROM @telData

UNION
SELECT 
t.vin ,
Convert.ToString(outsideTemperature) AS outsideTemperature 
EventProcessedUtcTime ,
PartitionId ,
EventEnqueuedUtcTime ,
IoTHub 
FROM 
@telData AS t 

UNION

SELECT 
t.vin ,
Convert.ToString(outsideTemperature) AS outsideTemperature 
EventProcessedUtcTime ,
PartitionId ,
EventEnqueuedUtcTime ,
IoTHub 

FROM 
@telData1 AS t;


OUTPUT @telDataResult
TO 
@"wasb://blobcontainer@blobstorage.blob.core.windows.net/cluster/logs/2016/outputofADLA.csv"
USING Outputters.Csv();

1 个答案:

答案 0 :(得分:0)

当您使用本机输出器时,各个行以多个顶点以并行方式写入,因此无法保证顺序。我们目前正致力于本地支持标题行的输出。在此期间,您可以使用我们的自定义输出器将标题行写入输出文件。自定义输出器可以在https://github.com/Azure/usql/tree/master/Examples/HeaderOutputter中找到。使用HeaderOutputter,您的代码将如下所示。

@telDataResult= SELECT 
 t.vin ,
 Convert.ToString(outsideTemperature) AS outsideTemperature 
 EventProcessedUtcTime ,
 PartitionId ,
 EventEnqueuedUtcTime ,
 IoTHub 
 FROM 
      @telData;

OUTPUT @telDataResult TO <OutputFile>
USING new new HeaderOutputter.HeaderOutputter(quoting:false);