简体   繁体   English

Azure Data Lake Analytics-输出日期为+0000而不是-0800

[英]Azure Data Lake Analytics - Output dates as +0000 rather than -0800

I have a datetime column in an Azure Data Lake Analytics table. 我在Azure Data Lake Analytics表中有一个datetime列。

All my incoming data is UTC +0000. 我所有传入的数据都是UTC +0000。 When using the below code, all the csv outputs convert the dates to -0800 使用以下代码时,所有csv输出都将日期转换为-0800

OUTPUT @data
TO @"/data.csv"
USING Outputters.Text(quoting : false, delimiter : '|');

An example datatime in the output: 输出中的示例数据时间:

2018-01-15T12:20:13.0000000-08:00 2018-01-15T12:20:13.0000000-08:00

Are there any options for controlling the output format of the dates? 有什么选项可以控制日期的输出格式? I don't really understand why everything is suddenly in -0800 when the incoming data isn't. 我真的不明白为什么当输入数据不在时,所有内容突然都在-0800中。

Currently, ADLA does not store TimeZone information in DateTime, meaning it will always default to the local time of the cluster machine when reading (-8:00 in your case). 当前,ADLA不在DateTime中存储TimeZone信息,这意味着在读取时它将始终默认为群集计算机的本地时间(在您的情况下为-8:00)。 Therefore, you can either normalize your DateTime to this local time by running 因此,您可以通过运行以下命令将DateTime标准化为该本地时间

DateTime.SpecifyKind(myDate, DateTimeKind.Local)    

or use 或使用

DateTime.ConvertToUtc() 

to output in Utc form (but note that next time you ingest that same data, ADLA will still default to reading it in offset -0800). 以Utc格式输出(但请注意,下次您提取相同的数据时,ADLA仍将默认使用偏移量-0800进行读取)。 Examples below: 下面的例子:

@getDates = 
EXTRACT
    id          int,
    date        DateTime
FROM "/test/DateTestUtc.csv"
USING Extractors.Csv();

@formatDates = 
SELECT
    id,
    DateTime.SpecifyKind(date, DateTimeKind.Local) AS localDate,
    date.ConvertToUtc() AS utcDate
FROM @getDates;


OUTPUT @formatDates
TO "/test/dateTestUtcKind_AllUTC.csv"
USING Outputters.Csv();

You can file a feature request for DateTime with offset on our ADL feedback site . 您可以在我们的ADL反馈网站上向DateTime提交具有偏移量的功能请求。 Let me know if you have other questions! 如果您还有其他问题,请告诉我!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM