Skip to content

feat(core): use timestamp range replace updates to update mat views#5679

Merged
bluestreak01 merged 76 commits intomasterfrom
feat-commit-with-replace-range
Jun 5, 2025
Merged

feat(core): use timestamp range replace updates to update mat views#5679
bluestreak01 merged 76 commits intomasterfrom
feat-commit-with-replace-range

Conversation

@ideoma
Copy link
Copy Markdown
Collaborator

@ideoma ideoma commented May 15, 2025

This PR implements a new "replace commit" mechanism for materialized view refreshes, using timestamp ranges to replace affected rows rather than relying on deduplication. Key changes include removing dedup key handling in MV creation, extending WAL commit methods to incorporate new timestamp range and deduplication mode parameters, and updating downstream consumers (e.g. query logging, O3 partition jobs, TxWriter) to support the new update scheme.

An example of a replace commit can be:

  • base table has changes in the time range from 2022-02-24T04 to 2022-02-24T05:31
  • materialized view MV exists with hourly aggregations
  • MV Reresh re-calculates the changes from 2022-02-24T04 to 2022-02-24T06
  • MV Reresh commits the refresh query output into the mat view. This new commit specifies the replace range from 2022-02-24T04 to 2022-02-24T06
  • WAL application procs replace all the existing rows in the range from 2022-02-24T04 to 2022-02-24T06 with the new rows.

This feature removes dedup restrictions on the base table, it can also solve a few more restrictions, like partition drop in the future.

ideoma added 30 commits March 24, 2025 17:57
…place-range

 Conflicts:
	core/src/main/java/io/questdb/cairo/wal/WalEventWriter.java
	core/src/main/java/io/questdb/cairo/wal/WalTxnDetails.java
	core/src/main/java/io/questdb/cairo/wal/WalWriter.java
	core/src/test/java/io/questdb/test/tools/TestUtils.java
…place-range

 Conflicts:
	core/src/main/java/io/questdb/cairo/TableWriter.java
	core/src/main/java/io/questdb/cairo/mv/MatViewRefreshExecutionContext.java
	core/src/main/java/io/questdb/cairo/mv/MatViewRefreshJob.java
	core/src/main/java/io/questdb/griffin/engine/QueryProgress.java
	core/src/test/java/io/questdb/test/cairo/fuzz/CheckpointFuzzTest.java
	core/src/test/java/io/questdb/test/cairo/fuzz/FuzzRunner.java
	core/src/test/java/io/questdb/test/cairo/fuzz/WalWriterFuzzTest.java
@puzpuzpuz puzpuzpuz self-requested a review June 2, 2025 10:04
@ideoma ideoma marked this pull request as ready for review June 2, 2025 17:45
…place-range

 Conflicts:
	core/src/test/java/io/questdb/test/cairo/mv/MatViewTest.java
@puzpuzpuz
Copy link
Copy Markdown
Contributor

@ideoma tests are failing + there is a number of merge conflicts to resolve

@bluestreak01 bluestreak01 removed the DO NOT MERGE These changes should not be merged to main branch label Jun 3, 2025
@glasstiger
Copy link
Copy Markdown
Contributor

[PR Coverage check]

😍 pass : 384 / 423 (90.78%)

file detail

path covered line new line coverage
🔵 io/questdb/cutlass/http/client/HttpClient.java 0 6 00.00%
🔵 io/questdb/cairo/mv/MatViewRefreshJob.java 41 64 64.06%
🔵 io/questdb/griffin/engine/functions/catalogue/DumpThreadStacksFunctionFactory.java 8 10 80.00%
🔵 io/questdb/cairo/frm/file/ContiguousFileFixFrameColumn.java 9 10 90.00%
🔵 io/questdb/cairo/TxReader.java 11 12 91.67%
🔵 io/questdb/cairo/mv/MatViewGraph.java 11 12 91.67%
🔵 io/questdb/cairo/wal/WalEventCursor.java 13 14 92.86%
🔵 io/questdb/cairo/TxWriter.java 19 20 95.00%
🔵 io/questdb/cairo/wal/WalTxnDetails.java 26 27 96.30%
🔵 io/questdb/cairo/O3PartitionJob.java 94 96 97.92%
🔵 io/questdb/cairo/wal/WalEventWriter.java 12 12 100.00%
🔵 io/questdb/cairo/frm/file/FrameImpl.java 14 14 100.00%
🔵 io/questdb/cairo/wal/WalWriter.java 26 26 100.00%
🔵 io/questdb/cairo/wal/WalEventReader.java 1 1 100.00%
🔵 io/questdb/cairo/mv/WalTxnRangeLoader.java 9 9 100.00%
🔵 io/questdb/cairo/wal/WalUtils.java 2 2 100.00%
🔵 io/questdb/griffin/engine/functions/date/TimestampFloorFromOffsetFunctionFactory.java 5 5 100.00%
🔵 io/questdb/cairo/mv/SampleByIntervalIterator.java 1 1 100.00%
🔵 io/questdb/griffin/FunctionParser.java 2 2 100.00%
🔵 io/questdb/cairo/frm/file/ContiguousFileVarFrameColumn.java 4 4 100.00%
🔵 io/questdb/cairo/O3OpenColumnJob.java 41 41 100.00%
🔵 io/questdb/cairo/CairoEngine.java 2 2 100.00%
🔵 io/questdb/std/datetime/AbstractTimeZoneRules.java 5 5 100.00%
🔵 io/questdb/cairo/frm/FrameAlgebra.java 11 11 100.00%
🔵 io/questdb/griffin/SqlCompilerImpl.java 5 5 100.00%
🔵 io/questdb/cairo/vm/MemoryCARWImpl.java 3 3 100.00%
🔵 io/questdb/cairo/frm/file/FrameFactory.java 3 3 100.00%
🔵 io/questdb/cairo/mv/MatViewDefinition.java 2 2 100.00%
🔵 io/questdb/tasks/O3PartitionTask.java 4 4 100.00%

@puzpuzpuz puzpuzpuz self-requested a review June 5, 2025 10:07
@bluestreak01 bluestreak01 merged commit 2b8f93f into master Jun 5, 2025
37 checks passed
@bluestreak01 bluestreak01 deleted the feat-commit-with-replace-range branch June 5, 2025 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants