Skip to content

feat(sql): period sample by interval syntax for materialized views#6428

Merged
bluestreak01 merged 6 commits intomasterfrom
puzpuzpuz_period_ignore_last_bucket
Nov 25, 2025
Merged

feat(sql): period sample by interval syntax for materialized views#6428
bluestreak01 merged 6 commits intomasterfrom
puzpuzpuz_period_ignore_last_bucket

Conversation

@puzpuzpuz
Copy link
Copy Markdown
Contributor

@puzpuzpuz puzpuzpuz commented Nov 21, 2025

Introduces new PERIOD (SAMPLE BY INTERVAL) syntax for period materialized views:

CREATE MATERIALIZED VIEW trades_daily_prices
REFRESH PERIOD (SAMPLE BY INTERVAL) AS
SELECT
  timestamp,
  symbol,
  avg(price) AS avg_price
FROM trades
SAMPLE BY 1d ALIGN TO CALENDAR TIME ZONE 'Europe/London';

The above SQL is an easier way to write PERIOD (LENGTH 1d TIME ZONE 'Europe/London').

Other than that, period materialized views now support second unit ('s') for the length and delay intervals. Prior to this change, the only supported units were minutes ('m'), hours ('h'), and days ('d').

Limitations:

  • SAMPLE BY ... WITH OFFSET ... can't be combined with PERIOD (SAMPLE BY INTERVAL).

@puzpuzpuz puzpuzpuz self-assigned this Nov 21, 2025
@puzpuzpuz puzpuzpuz added Enhancement Enhance existing functionality SQL Issues or changes relating to SQL execution labels Nov 21, 2025
@puzpuzpuz puzpuzpuz marked this pull request as draft November 21, 2025 15:06
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 21, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch puzpuzpuz_period_ignore_last_bucket

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@bluestreak01
Copy link
Copy Markdown
Member

@CodeRabbit review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 21, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@puzpuzpuz puzpuzpuz marked this pull request as ready for review November 24, 2025 14:03
@bluestreak01 bluestreak01 merged commit d4a0d43 into master Nov 25, 2025
19 of 39 checks passed
@bluestreak01 bluestreak01 deleted the puzpuzpuz_period_ignore_last_bucket branch November 25, 2025 12:23
@glasstiger
Copy link
Copy Markdown
Contributor

[PR Coverage check]

😍 pass : 140 / 147 (95.24%)

file detail

path covered line new line coverage
🔵 io/questdb/griffin/engine/ops/CreateMatViewOperationImpl.java 20 23 86.96%
🔵 io/questdb/griffin/engine/ops/CreateMatViewOperation.java 17 18 94.44%
🔵 io/questdb/griffin/SqlCompilerImpl.java 51 53 96.23%
🔵 io/questdb/griffin/SqlParser.java 47 48 97.92%
🔵 io/questdb/griffin/engine/ops/CreateMatViewOperationBuilderImpl.java 3 3 100.00%
🔵 io/questdb/cairo/mv/MatViewDefinition.java 2 2 100.00%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Enhance existing functionality SQL Issues or changes relating to SQL execution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants