Amit Baghel created SPARK-17174:
-----------------------------------
Summary: Provide support for Timestamp type Column in add_months
function to return HH:mm:ss
Key: SPARK-17174
URL: https://issues.apache.org/jira/browse/SPARK-17174
Project: Spark
Issue Type: Improvement
Components: Spark Core
Affects Versions: 2.0.0
Reporter: Amit Baghel
Priority: Minor
add_months function currently supports Date types. If Column is Timestamp type
then it adds month to date but it doesn't return timestamp part (HH:mm:ss). See
the code below.
import java.util.Calendar
val now = Calendar.getInstance().getTime()
val df = sc.parallelize((0 to 3).map(i => {now.setMonth(i); (i, new
java.sql.Timestamp(now.getTime))}).toSeq).toDF("ID", "DateWithTS")
df.withColumn("NewDateWithTS", add_months(df("DateWithTS"),1)).show
Above code gives following response. See the HH:mm:ss is missing from
NewDateWithTS column.
+---+--------------------+-------------+
| ID| DateWithTS|NewDateWithTS|
+---+--------------------+-------------+
| 0|2016-01-21 09:38:...| 2016-02-21|
| 1|2016-02-21 09:38:...| 2016-03-21|
| 2|2016-03-21 09:38:...| 2016-04-21|
| 3|2016-04-21 09:38:...| 2016-05-21|
+---+--------------------+-------------+
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]