Aleksandr Zakharchenko
06/23/2026, 7:43 PMRocky
06/23/2026, 7:43 PMREFRESH ASYNC EVERY clause.
sql
CREATE MATERIALIZED VIEW iceberg_mv
-- Optional: Partitioning the MV by the same column as the base table
-- allows StarRocks to refresh only changed partitions (Incremental Refresh).
PARTITION BY (dt)
DISTRIBUTED BY HASH(id)
REFRESH ASYNC EVERY (INTERVAL 5 MINUTE) -- Set your desired refresh frequency
AS
SELECT * FROM iceberg_catalog_hms.test.test_table;
2. Key Considerations for Iceberg MVs
* Partition-Level Refresh (Incremental): Since StarRocks v3.1.4+, the engine can detect data changes in Iceberg at the partition level. If your Iceberg table is partitioned (e.g., by dt) and your MV is also partitioned by that same column, StarRocks will only refresh the partitions that have changed since the last refresh, significantly saving resources.
* Metadata Polling: For the MV to "see" that the Iceberg table has changed, StarRocks needs to refresh its metadata cache. Starting from v3.3.3, StarRocks supports a periodic metadata refresh strategy for Iceberg.
* Ensure the FE configuration enable_iceberg_metadata_disk_cache is enabled (default) or that you haven't disabled background metadata refreshing.
* Query Rewrite Staleness: If you want your queries to be automatically rewritten to use this MV even if the MV is a few seconds/minutes behind the base Iceberg table, you can set the staleness property:
sql
ALTER MATERIALIZED VIEW iceberg_mv SET ("mv_rewrite_staleness_second" = "300");
3. Monitoring the Refresh
Because these refreshes happen in the background, you can monitor the status and history of the "auto" tasks using:
sql
-- Check the status of the MV refresh tasks
SELECT * FROM information_schema.task_runs
WHERE task_name LIKE 'mv-%'
ORDER BY create_time DESC;
-- Manually trigger a refresh if needed
REFRESH MATERIALIZED VIEW iceberg_mv;
Summary for your environment
* Shared-data mode: Refresh tasks will run on your default warehouse. Ensure your compute nodes have sufficient resources for the background INSERT OVERWRITE operations.
* Kubernetes-operator: Ensure your FE has network access to the Hive Metastore (HMS) and the underlying Iceberg storage (S3/HDFS) to perform the metadata checks and data pulls.
References
• using_starrocks/async_mv/use_cases/data_lake_query_acceleration_with_materialized_views.md
• sql-reference/sql-statements/materialized_view/CREATE_MATERIALIZED_VIEW.md
• data_source/catalog/iceberg/iceberg_catalog.mdAleksandr Zakharchenko
06/23/2026, 7:50 PMRocky
06/23/2026, 7:51 PMauto refresh mode is controlled by the refresh_mode property. This mode allows StarRocks to automatically choose the most efficient refresh strategy (Incremental vs. Full/PCT) for each refresh task.
To leverage this, you include "refresh_mode" = "auto" in the PROPERTIES clause of your CREATE MATERIALIZED VIEW statement.
Recommended Syntax
For an Iceberg table in an HMS catalog, the definition would look like this:
sql
CREATE MATERIALIZED VIEW iceberg_auto_mv
-- 1. Partitioning is required for Incremental Refresh to work
PARTITION BY (dt)
DISTRIBUTED BY HASH(id)
-- 2. Set your refresh schedule
REFRESH ASYNC EVERY (INTERVAL 1 HOUR)
PROPERTIES (
-- 3. The new v4.1 property
"refresh_mode" = "auto"
)
AS
SELECT * FROM iceberg_catalog_hms.test.test_table;
How refresh_mode Works
* auto (New in v4.1): StarRocks attempts an incremental refresh (refreshing only the changed partitions in Iceberg). If an incremental refresh is not possible (e.g., due to a non-partitioned change, a complex join, or metadata issues), it automatically falls back to a full refresh (PCT mode). This provides the best balance of performance and reliability.
* incremental: Forces StarRocks to perform only incremental refreshes. If the refresh cannot be done incrementally for any reason, the task will fail rather than falling back to a full refresh.
* pct (Legacy/Default): Always performs a full refresh of the materialized view partitions.
Important Notes for v4.1.1
1. Rebuilding Required: You cannot ALTER an existing materialized view created with the legacy PCT mode to use auto. You must drop and recreate the MV to enable the new refresh engine logic.
2. Iceberg Partition Transforms: If your Iceberg table uses partition transforms (like day(ts) or month(ts)), ensure your MV's PARTITION BY expression matches the corresponding StarRocks function (e.g., date_trunc('day', ts)) to ensure the auto mode can successfully map partitions for incremental updates.
3. Monitoring: You can verify which mode was actually used for a specific run by checking the EXTRA_MESSAGE column in the information_schema.task_runs table:
sql
SELECT task_name, create_time, state, extra_message
FROM information_schema.task_runs
ORDER BY create_time DESC LIMIT 5;
The extra_message JSON will contain a "refreshMode" field indicating whether that specific run was INCREMENTAL or PCT.
References
• sql-reference/sql-statements/materialized_view/CREATE_MATERIALIZED_VIEW.md
• using_starrocks/async_mv/use_cases/data_lake_query_acceleration_with_materialized_views.md
References
• release_notes/release-3.3.md
• release_notes/release-2.5.mdAleksandr Zakharchenko
06/23/2026, 8:32 PMRocky
06/23/2026, 8:33 PMrefresh_mode property exists in StarRocks 4.1.1, the value auto is not currently an allowed option in the DDL for that specific version.
In StarRocks 4.1.x, the "AUTO" mode was introduced to automatically switch between the new row-level incremental engine (IVM) and the classic partition-level engine (PCT). However, in version 4.1.1, several behaviors regarding this feature were restricted or disabled (as noted in the 4.1.1 release notes and PR #71355).
How to Fix the Error
To achieve an "auto-refreshing" materialized view (MV) on Iceberg in StarRocks 4.1.1, you should choose one of the two supported modes:
Option 1: refresh_mode = "INCREMENTAL" (Recommended for Iceberg)
This uses the new Incremental Refresh (IVM) engine introduced in v4.1. It is designed specifically for Iceberg append-only tables to process only the delta changes (rows) rather than entire partitions.
sql
CREATE MATERIALIZED VIEW iceberg_mv
PARTITION BY (dt)
DISTRIBUTED BY HASH(id)
REFRESH ASYNC EVERY (INTERVAL 5 MINUTE)
PROPERTIES (
"refresh_mode" = "INCREMENTAL"
)
AS
SELECT * FROM iceberg_catalog_hms.test.test_table;
Option 2: refresh_mode = "PCT" (The Default)
This uses the classic Partition-level Incremental Refresh. If your Iceberg table is partitioned, StarRocks will detect which partitions have changed and refresh only those partitions.
sql
CREATE MATERIALIZED VIEW iceberg_mv
PARTITION BY (dt)
DISTRIBUTED BY HASH(id)
REFRESH ASYNC EVERY (INTERVAL 5 MINUTE)
PROPERTIES (
"refresh_mode" = "PCT"
)
AS
SELECT * FROM iceberg_catalog_hms.test.test_table;
Key Differences in 4.1.1
* Query Rewrite: Note that in version 4.1.1, query rewrite is currently disabled for MVs using refresh_mode = "INCREMENTAL". If you need your queries to be automatically routed to the MV, you should use refresh_mode = "PCT" for now.
* Automatic Triggering: For Iceberg (and all external catalogs), StarRocks does not yet support "event-triggered" refresh (where the MV updates the instant a commit happens in Iceberg). You must use the REFRESH ASYNC EVERY clause to set a polling interval.
Summary
If your goal is to have the MV update itself without manual intervention, the "auto" part comes from the REFRESH ASYNC schedule, not the refresh_mode. Use INCREMENTAL for the most efficient resource usage on Iceberg, or PCT if you require query rewrite support for automatic query rewriting.
References
• sql-reference/sql-statements/materialized_view/CREATE_MATERIALIZED_VIEW.md
• using_starrocks/async_mv/use_cases/data_lake_query_acceleration_with_materialized_views.md
• release_notes/release-3.3.md