Problem
When attempting to add or update a comment on a streaming table using the COMMENT ON TABLE
SQL command, you encounter the following error.
[STREAMING_TABLE_OPERATION_NOT_ALLOWED.INVALID_ALTER]
The operation COMMENT ON TABLE is not allowed:
To alter the schema or properties of Streaming Tables, please use the CREATE OR REFRESH command.
Cause
Databricks manages the schema and properties of Lakeflow Declarative Pipelines exclusively through the pipeline definition and controlled refresh cycles. Direct DDL operations (outside the pipeline code or refresh commands) are blocked to maintain metadata consistency and proper pipeline operation.
Solution
To add or update comments or constraints, first edit the Lakeflow Declarative Pipeline code to reflect your desired schema or property change.
You can add a comment in the Lakeflow Declarative Pipelines using a tag, either in the materialized view or in the streaming table. The following code provides an example line modification.
@Dlt.table(
comment = "<your-comment>"
)
Then deploy or refresh the pipeline to apply the modification.
For more information, refer to the CREATE MATERIALIZED VIEW (Lakeflow Declarative Pipelines) (AWS | Azure | GCP) and the table (AWS | Azure | GCP) documentation.
Additionally, avoid executing standalone DDL commands on Lakeflow Declarative Pipeline tables in notebooks, Databricks SQL, or API calls.