How to add Current date as one of the column in Databricks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 08:33 PM
I am trying to create new column "Ingest_date" in table which should contain current date. I am getting error "Current date cannot be used in a generated column". Can you please review and suggest alternative to get the current date in delta table.
- Labels:
-
Current Date
-
Date
-
GENERATED ALWAYS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 11:59 PM
A generation expression can use any SQL functions in Spark that always return the same result when given the same argument values
Source: https://docs.delta.io/latest/delta-batch.html#use-generated-columns
It means that it's intended to not work.
You can still insert the value of current_date() in your ingestion pipeline.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2023 11:39 AM
Thank you Daniel. Appreciate your inputs.
This is the requirement which i am trying to achieve. I will create a table with 5 columns and 4 columns will be inserted by process . Ingest date column should be populated with current date when columns are inserted.

