Trying to add a Delta Lake generated column using SQL, and then partition by it. I am following the Databricks documentation which provide the following example:
CREATE TABLE events(
eventId BIGINT,
data STRING,
eventType STRING,
eventTime TIMESTAMP,
eventDate date GENERATED ALWAYS AS (CAST(eventTime AS DATE))
)
PARTITIONED BY (eventType, eventDate)
My question is: how can I alter this code for an existing table? What I want to accomplish is to do something like GENERATED ALWAYS AS (CAST(eventTime AS DATE))
to an existing table and then partition by this generated column.
This question is related, but does not focus on using GENERATED.