Help Center/ MapReduce Service/ Component Operation Guide (LTS)/ Using Spark/Spark2x/ Spark Troubleshooting/ How Do I Use Special Characters with TIMESTAMP and DATE?
Updated on 2024-10-09 GMT+08:00

How Do I Use Special Characters with TIMESTAMP and DATE?

Question

In versions later than Spark 3.2.0, TIMESTAMP(*) or DATE(*) is not supported. The asterisk (*) can be any of the following characters:

  • epoch
  • today
  • yesterday
  • tomorrow
  • now

The default format supported is either the timestamp '*' or data '*' format. If the previous syntax is used to insert data into the data table, a NULL value will be returned.

Answer

To make the spark.sql.convert.special.datetime parameter compatible with the previous syntax, run the following command on the Spark client:

set spark.sql.convert.special.datetime=true;