feat(sql): breaking change 💥 - period refresh for materialized views#5723
Merged
feat(sql): breaking change 💥 - period refresh for materialized views#5723
Conversation
Also includes the following: * Updates the syntax to be compatible with upcoming period refresh. `REFRESH INCREMENTAL` is replaced with `REFRESH IMMEDIATE` * Adds optional TIME ZONE clause for timer materialized views
…to puzpuzpuz_period_mat_views
6dfe52a to
8317827
Compare
ideoma
reviewed
Jun 27, 2025
33c7987 to
2464614
Compare
ideoma
previously approved these changes
Jun 30, 2025
Co-authored-by: Alex Pelagenko <[email protected]>
ideoma
approved these changes
Jun 30, 2025
Contributor
Author
|
@ideoma thanks for the comprehensive review! |
bluestreak01
approved these changes
Jun 30, 2025
Contributor
[PR Coverage check]😍 pass : 1007 / 1077 (93.50%) file detail
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documentation PR: questdb/documentation#202
Ent PR: https://github.com/questdb/questdb-enterprise/pull/634
Includes the following new features and enhancements for materialized views:
mat.view.debug.enabled=trueconfig property)REFRESH INCREMENTALis replaced withREFRESH IMMEDIATE, but older syntax is also acceptedBreaking change 0: previously set REFRESH LIMIT and REFRESH EVERY (timer refresh) settings will be reset by this patch. Materialized views with timer refresh will be treated as manual refresh ones. To restore a timer view, it has to be dropped and recreated. To restore the REFRESH LIMIT, an alter statement must be executed after the upgrade. Example:
Breaking change 1: updated syntax for timer refresh. Instead of
REFRESH START <timestamp> EVERY <interval>in CREATE MATERIALIZED VIEW and ALTER MATERIALIZED VIEW we now expectREFRESH EVERY <interval> START <timestamp>syntax.Period materialized views
Adds special period type of materialized views. These materialized views never aggregate data on incomplete period interval, e.g. current day, and only refresh older periods. Once the current period is over, it's refreshed automatically (unless the materialized view is configured for manual refresh). Inserts into complete periods are reflected in the view data just like with non-period materialized views.
The above materialized view will start refreshing one-day periods on the next day after it was created, at 02:00 in Berlin time zone (CEST). The time is 2 hours past the end of the period due to the
2hdelay value. Since this view has the default IMMEDIATE refresh type, all writes to the base table that are older than the current period will be asynchronously reflected in thetrades_latest_1dview.Full REFRESH PERIOD syntax:
For now, the maximum period length is limited with 24 hours.
Internally, a new
lastPeriodHipersisted field is added to materialized view state to track the last refreshed period interval.Manual refresh for materialized views
Manual refresh materialized views can be refreshed via the
REFRESH MATERIALIZED VIEW price_1h INCREMENTAL;syntax or, if the view became invalid via theREFRESH MATERIALIZED VIEW price_1h FULL;syntax. The incremental refresh steps are the same as for IMMEDIATE and timer (EVERY) materialized views except for the only way to trigger a refresh on a manual view is via REFRESH SQL.TIME ZONE clause
The optional TIME ZONE clause is available for materialized views with timer refresh and period materialized views. When specified, the time zone is applied to both start timestamp and timer intervals.
DDL example with the new TIME ZONE clause:
DEFERRED clause
The default behavior now is to refresh the view once it's created, but when the
DEFERREDclause is specified, the view will only refresh on the corresponding event, e.g. explicitREFRESHSQL in case of manual refresh.