ALTER STREAMING TABLE
This feature is in Public Preview.
Applies to: Databricks SQL
Allows you to perform any of the following actions:
- Add a schedule or trigger for refreshing an existing streaming table.
- Alter an existing refresh schedule or trigger for a streaming table.
- Drop the refresh schedule or trigger for a streaming table. If there is no schedule or trigger, the object needs to be refreshed manually to reflect the latest data.
To add or alter a comment on a table, use COMMENT ON.
Syntax
ALTER STREAMING TABLE table_name
{
{ ADD | ALTER } schedule
DROP SCHEDULE |
ALTER COLUMN clause |
SET ROW FILTER clause |
DROP ROW FILTER |
SET TAGS clause |
UNSET TAGS clause |
}
schedule
{ SCHEDULE [ REFRESH ] schedule_clause |
TRIGGER ON UPDATE [ AT MOST EVERY trigger_interval ] }
schedule_clause
{ EVERY number { HOUR | HOURS | DAY | DAYS | WEEK | WEEKS } |
CRON cron_string [ AT TIME ZONE timezone_id ] }
Parameters
-
The name of the streaming table to alter the definition of. The name must not include a temporal specification.
-
schedule
Add or alter a
SCHEDULE
orTRIGGER
statement on the table.-
SCHEDULE [ REFRESH ] schedule_clause
-
EVERY number { HOUR | HOURS | DAY | DAYS | WEEK | WEEKS }
To schedule a refresh that occurs periodically, use
EVERY
syntax. IfEVERY
syntax is specified, the streaming table or materialized view is refreshed periodically at the specified interval based on the provided value, such asHOUR
,HOURS
,DAY
,DAYS
,WEEK
, orWEEKS
. The following table lists accepted integer values fornumber
.Time unit
Integer value
HOUR or HOURS
1 <= H <= 72
DAY or DAYS
1 <= D <= 31
WEEK or WEEKS
1 <= W <= 8
noteThe singular and plural forms of the included time unit are semantically equivalent.
-
CRON cron_string [ AT TIME ZONE timezone_id ]
To schedule a refresh using a quartz cron value. Valid time_zone_values are accepted.
AT TIME ZONE LOCAL
is not supported.If
AT TIME ZONE
is absent, the session time zone is used. IfAT TIME ZONE
is absent and the session time zone is not set, an error is thrown.SCHEDULE
is semantically equivalent toSCHEDULE REFRESH
.
-
-
TRIGGER ON UPDATE [ AT MOST EVERY trigger_interval ]
BetaThe
TRIGGER ON UPDATE
feature is in Beta. To enable this feature in your workspace, reach out to your Databricks representative.Sets the table to refresh when an upstream data source is updated, at most once every minute. Set a value for
AT MOST EVERY
to require at least a minimum time between refreshes.The upstream data sources must be either external or managed Delta tables (including materialized views or streaming tables), or managed views whose dependencies are limited to supported table types.
Enabling file events can make triggers more performant, and increases some of the limits on trigger updates.
The
trigger_interval
is an INTERVAL statement that is at least 1 minute.TRIGGER ON UPDATE
has the following limitations- No more than 10 upstream data sources per streaming table using table triggers.
- Maximum of 50 streaming tables or materialized views using table triggers (enabling file events on upstream data sources removes this limit).
- For source data in an external Delta table, there is a limit of 10,000 rows per change set (enabling file events on upstream data sources removes this limit).
- The
AT MOST EVERY
clause defaults to 1 minute, and cannot be less than 1 minute.
-
-
Preview
This feature is in Public Preview.
Changes a property of a column.
-
Preview
This feature is in Public Preview.
Adds a row filter function to the streaming table. All subsequent queries to the streaming table receive a subset of the rows where the function evaluates to boolean
TRUE
. This can be useful for fine-grained access control purposes where the function can inspect the identity or group memberships of the invoking user to determine whether to filter certain rows. -
DROP ROW FILTER
PreviewThis feature is in Public Preview.
Drops the row filter from the streaming table, if any. Future queries return all rows from the table without any automatic filtering.
-
SET TAGS ( { tag_name = tag_value } [, ...] )
PreviewThis feature is in Public Preview.
Apply tags to the streaming table. You need to have
APPLY TAG
permission to add tags to the streaming table.-
tag_name
A literal
STRING
. Thetag_name
must be unique within the streaming table or column. -
tag_value
A literal
STRING
.
-
-
UNSET TAGS ( tag_name [, ...] )
PreviewThis feature is in Public Preview.
Remove tags from the streaming table. You need to have
APPLY TAG
permission to remove tags from the streaming table.-
tag_name
A literal
STRING
. Thetag_name
must be unique within the streaming table or column.
-
Examples
-- Adds a schedule to refresh the streaming table once a day
-- at midnight in Los Angeles
> ALTER STREAMING TABLE my_st
ADD SCHEDULE CRON '0 0 0 * * ? *' AT TIME ZONE 'America/Los_Angeles';
-- Alters the schedule to run every 15 minutes for a streaming table
> ALTER STREAMING TABLE my_st
ALTER SCHEDULE EVERY 15 MINUTES;
-- Drops the schedule for a streaming table
> ALTER STREAMING TABLE my_st
DROP SCHEDULE;