Skip to content

feat(sql): ALTER MATERIALIZED VIEW SET REFRESH support#5896

Merged
bluestreak01 merged 59 commits intomasterfrom
puzpuzpuz_alter_mat_view_refresh2
Jul 10, 2025
Merged

feat(sql): ALTER MATERIALIZED VIEW SET REFRESH support#5896
bluestreak01 merged 59 commits intomasterfrom
puzpuzpuz_alter_mat_view_refresh2

Conversation

@puzpuzpuz
Copy link
Copy Markdown
Contributor

@puzpuzpuz puzpuzpuz commented Jul 7, 2025

Makes possible to change any of the REFRESH settings for the given materialized view. Example:

CREATE MATERIALIZED VIEW price_1h
REFRESH IMMEDIATE AS
SELECT sym, last(price) AS price, ts
FROM base_price
SAMPLE BY 1h;

-- it's now possible to change the above view to period refresh
ALTER MATERIALIZED VIEW price_1h SET REFRESH PERIOD (LENGTH 1d DELAY 1h);

puzpuzpuz and others added 30 commits July 1, 2025 14:23
… in case of manual and timer materialized views
@puzpuzpuz puzpuzpuz self-assigned this Jul 7, 2025
@puzpuzpuz puzpuzpuz added New feature Feature requests SQL Issues or changes relating to SQL execution labels Jul 7, 2025
@puzpuzpuz puzpuzpuz marked this pull request as ready for review July 7, 2025 16:09
ideoma
ideoma previously approved these changes Jul 8, 2025
);
updateMatViewDefinition(newDefinition);
} finally {
path.trimTo(pathSize);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use path here, debis?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to updateMatViewDefinition() in 71117f1

I also noticed that we were publishing timer tasks before the mat view state is initialized. This is not a big deal as in that case timer job does nothing when the timer is triggered until the state is initialized, but make thing more aligned, I moved publishing timer tasks to state store in 98b0783

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL

@puzpuzpuz
Copy link
Copy Markdown
Contributor Author

@ideoma thanks for the review!

@glasstiger
Copy link
Copy Markdown
Contributor

[PR Coverage check]

😍 pass : 241 / 267 (90.26%)

file detail

path covered line new line coverage
🔵 io/questdb/cairo/wal/seq/MetadataServiceStub.java 0 1 00.00%
🔵 io/questdb/cairo/TableWriter.java 13 20 65.00%
🔵 io/questdb/cairo/mv/MatViewTimerJob.java 20 26 76.92%
🔵 io/questdb/cairo/mv/MatViewRefreshJob.java 32 41 78.05%
🔵 io/questdb/griffin/SqlParser.java 14 17 82.35%
🔵 io/questdb/griffin/engine/ops/AlterOperationBuilder.java 12 12 100.00%
🔵 io/questdb/griffin/engine/functions/date/TimestampFloorFromFunctionFactory.java 1 1 100.00%
🔵 io/questdb/griffin/engine/functions/date/TimestampFloorFromOffsetFunctionFactory.java 1 1 100.00%
🔵 io/questdb/cairo/mv/MatViewStateStoreImpl.java 12 12 100.00%
🔵 io/questdb/cairo/CairoEngine.java 2 2 100.00%
🔵 io/questdb/std/datetime/microtime/Timestamps.java 9 9 100.00%
🔵 io/questdb/griffin/SqlCompilerImpl.java 107 107 100.00%
🔵 io/questdb/cairo/mv/MatViewDefinition.java 4 4 100.00%
🔵 io/questdb/cairo/mv/MatViewGraph.java 1 1 100.00%
🔵 io/questdb/griffin/engine/ops/AlterOperation.java 13 13 100.00%

@bluestreak01 bluestreak01 merged commit fe0ccbb into master Jul 10, 2025
34 checks passed
@bluestreak01 bluestreak01 deleted the puzpuzpuz_alter_mat_view_refresh2 branch July 10, 2025 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New feature Feature requests SQL Issues or changes relating to SQL execution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants