GitHub user HyukjinKwon opened a pull request:
https://github.com/apache/spark/pull/14279
[SPARK-16216][SQL] Write Timestamp and Date in ISO 8601 formatted string by
default for CSV and JSON
## What changes were proposed in this pull request?
Currently, CSV datasource is writing `Timestamp` and `Date` as numeric form
and JSON datasource is writing both as below:
- CSV
```
// TimestampType
1414459800000000
// DateType
16673
```
- Json
```
// TimestampType
1970-01-01 11:46:40.0
// DateType
1970-01-01
```
So, for CSV we can't read back what we write and for JSON it becomes
ambiguous because the timezone is being missed.
So, this PR make both **write** `Timestamp` and `Date` in ISO 8601
formatted string (please refer the [ISO 8601
specification](https://www.w3.org/TR/NOTE-datetime)).
- For `Timestamp` it becomes as below: (`yyyy-MM-dd'T'HH:mm:ss.SZZ`)
```
1970-01-01T02:00:01.000-01:00
```
- For `Date` it becomes as below (`yyyy-MM-dd`)
```
1970-01-01
```
FYI, CSV and JSON users `DateTimeUtils.stringToTime(...)` to read data and
infer schema. This is already okay with ISO 8601 dates. So, this PR only deals
with writing.
## How was this patch tested?
Unit tests were added in `CSVSuite`. For JSON, existing tests cover them.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/HyukjinKwon/spark SPARK-16216-json-csv
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/14279.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #14279
----
commit 27de16da5b186a8b7afe911582f738896a285a37
Author: hyukjinkwon <[email protected]>
Date: 2016-07-20T06:42:51Z
Write Timestamp and Date in ISO8601 format by defalt
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]