SparkSQL saves Timestamp/DateType's as Longs
See original GitHub issueThe DataFrameValueWriter
contains the following:
case TimestampType => generator.writeNumber(value.asInstanceOf[Timestamp].getTime())
case DateType => generator.writeNumber(value.asInstanceOf[Date].getTime())
While the TimestampType is documented as being persisted as a long, the DateType is documented as being serialized and persisted as a Date string.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:13
- Comments:9
Top Results From Across the Web
How to Effectively Use Dates and Timestamps in Spark 3.0
Spark SQL defines the timestamp type as TIMESTAMP WITH SESSION TIME ZONE , which is a combination of the fields ( YEAR ,...
Read more >Does spark sql timestamp datatype actually store timezone?
sql.Timestamp * and are stored internally as longs, which are capable of storing timestamps with microsecond * precision. ref- spark-git.
Read more >Data Types - Spark 3.3.1 Documentation
TimestampType : Represents values comprising values of fields year, month, day, hour, minute, and second, with the session local time-zone. The timestamp value ......
Read more >Spark SQL Date and Timestamp Functions
All these accept input as, Date type, Timestamp type or String. ... Column, Returns the current Unix timestamp (in seconds) as a long....
Read more >java.sql.Timestamp Scala Example - ProgramCreek.com
package oharastream.ohara.connector.jdbc.datatype import java.sql. ... duration) def beWithinSeconds(seconds: Long)(expected: Timestamp) = new ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @jbaiera , I also notice this problem when I read the doc and this error appear 2 times, in Table9 and Table10 (https://www.elastic.co/guide/en/elasticsearch/hadoop/master/spark.html#spark-sql-type-conversion)
And my question is why we convert
Timestamp/Date
tolong
? Should we keep the same behaviors betweenJdkValueWriter
andDataFrameValueWriter
?Or maybe instead of converting
Timestamp/Date
tolong
ordate (string format)
, it would be better to offer an option in configuration to let users make the choice?Regards, Fangrou
I ran into the same problem today. Regardless if it a date or timestamp, the spark connector writes to ES as a number. Is there any way around this to write fields as date?