Description
Adding 'date_trunc' as a built-in function.
'date_trunc' is common in other databases, but Spark or Hive does not have support for this.
We do have 'trunc' but this only works with 'MONTH' and 'YEAR' level on the DateType input. ( https://spark.apache.org/docs/2.2.0/api/java/org/apache/spark/sql/functions.html#trunc-org.apache.spark.sql.Column-java.lang.String- )
'date_trunc' on other databases:
AWS Redshift: http://docs.aws.amazon.com/redshift/latest/dg/r_DATE_TRUNC.html
PostgreSQL: https://www.postgresql.org/docs/9.1/static/functions-datetime.html
Presto: https://prestodb.io/docs/current/functions/datetime.html
Attachments
Issue Links
- causes
-
SPARK-30793 Wrong truncations of timestamps before the epoch to minutes and seconds
- Resolved
-
SPARK-30857 Wrong truncations of timestamps before the epoch to hours and days
- Resolved
- is related to
-
SPARK-22844 R date_trunc API
- Resolved
- links to