GitHub user HyukjinKwon opened a pull request:
https://github.com/apache/spark/pull/13912
[SPARK-16216][SQL] CSV data source does not write date and timestamp
correctly
## What changes were proposed in this pull request?
This PR corrects CSV data sources in order to write `DateType` and
`TimestampType` correctly just like JSON data source.
Currently this writes the data as below:
```
+----------------+
| date|
+----------------+
|1440637200000000|
|1414459800000000|
|1454040000000000|
+----------------+
```
This PR make this write dates and timestamps in a formatted string as below:
- **TimestampType**
- With `dateFormat` option (e.g. `dd/MM/yyyy HH:mm`)
```
+----------------+
| date|
+----------------+
|2015/08/26 18:00|
|2014/10/27 18:30|
|2016/01/28 20:00|
+----------------+
```
- Without `dateFormat` option
```
+---------------------+
| date|
+---------------------+
|2015-08-26 18:00:00.0|
|2014-10-27 18:30:00.0|
|2016-01-28 20:00:00.0|
+---------------------+
```
- **DateType**
- With `dateFormat` option (e.g. `yyyy/MM/dd`)
```
+----------+
| date|
+----------+
|2015/08/26|
|2014/10/27|
|2016/01/28|
+----------+
```
- Without `dateFormat` option
```
+----------+
| date|
+----------+
|2015-08-26|
|2014-10-27|
|2016-01-28|
+----------+
```
## How was this patch tested?
Unit tests in `CsvSuite.scala`.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/HyukjinKwon/spark SPARK-16216
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/13912.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 #13912
----
commit 78785e078464c93541edd23abc9276800714cfdd
Author: hyukjinkwon <[email protected]>
Date: 2016-06-26T06:00:17Z
CSV data source does not write date and timestamp correctly
commit 79a290a654e67f678c0d7c5ba52825a75b089a70
Author: hyukjinkwon <[email protected]>
Date: 2016-06-26T06:08:50Z
Fix comments
----
---
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]