Skip to content

docs(sql): SAMPLE BY FILL - cross-column references for prev, fast-path and limitations#426

Open
jovfer wants to merge 2 commits into
mainfrom
sm_fill_prev_fast_path
Open

docs(sql): SAMPLE BY FILL - cross-column references for prev, fast-path and limitations#426
jovfer wants to merge 2 commits into
mainfrom
sm_fill_prev_fast_path

Conversation

@jovfer
Copy link
Copy Markdown
Contributor

@jovfer jovfer commented May 1, 2026

Summary

Refresh the SAMPLE BY FILL documentation to reflect what the fast-path implementation in questdb/questdb#6946 now accepts.

  • query/sql/sample-by.md
    • Add PREV(col) to the FILL options table and list its constraints (type match, no broadcast, no SYMBOL).
    • Replace the outdated "fill strategies cannot be combined" rule with the actual FILL(NONE) rule.
    • Rewrite FROM-TO Limitations: drop "not compatible with FILL(PREV)" and "does not consider OFFSET"; document that keyed FROM-TO works when bounds are constants and is rejected for bind variables, function calls, or arithmetic expressions.
  • cookbook/sql/time-series/fill-keyed-arbitrary-interval.md
    • Scope the recipe to the bind-variable / function-bound case, since constant-bound keyed FROM-TO is now supported natively.
  • cookbook/sql/time-series/fill-from-one-column.md
    • Replace the "imagine this SQL was valid" framing with the actual FILL(PREV(col)) syntax. Keep the window-function rewrite as the flexible alternative (e.g. flagging filled rows).

Test plan

  • Read the rendered pages locally and confirm the new restrictions and examples line up with the behaviour exercised by the FILL test suite.
  • Spot-check the linked anchors (#from-to, #fill-options) still resolve.

Update the SAMPLE BY reference and the related cookbook recipes to
match what the FILL fast path now accepts:

- sample-by.md: list PREV(col) in the FILL options table, replace the
  outdated "fill strategies cannot be combined" rule with the actual
  PREV(col) and FILL(NONE) constraints, and rewrite the FROM-TO
  Limitations to drop "not compatible with FILL(PREV)" and "does not
  consider OFFSET". Note that keyed FROM-TO is supported when FROM/TO
  are constants and is rejected for bind-variable / function /
  arithmetic bounds.
- fill-keyed-arbitrary-interval.md: scope the recipe to the
  bind-variable / function-bound case, since constant-bound keyed
  FROM-TO works natively.
- fill-from-one-column.md: replace the "imagine this SQL was valid"
  framing with the actual FILL(PREV(col)) syntax and keep the window-
  function rewrite as the more flexible alternative for cases such as
  flagging filled rows.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

🚀 Build success!

Latest successful preview: https://preview-426--questdb-documentation.netlify.app/docs/

Commit SHA: f0df257

📦 Build generates a preview & updates link on each commit.

@jovfer jovfer marked this pull request as ready for review May 6, 2026 15:16
@jovfer jovfer enabled auto-merge (squash) May 8, 2026 13:00
@jovfer jovfer changed the title docs(sql): cover SAMPLE BY FILL fast-path syntax and limitations docs(sql): cover SAMPLE BY FILL updates: cross-column references for prev, fast-path and limitations May 8, 2026
@jovfer jovfer changed the title docs(sql): cover SAMPLE BY FILL updates: cross-column references for prev, fast-path and limitations docs(sql): SAMPLE BY FILL - cross-column references for prev, fast-path and limitations May 8, 2026
Comment thread documentation/query/sql/sample-by.md Outdated
(= `2025-12-31T23:00:00Z` UTC).

`FROM-TO` can only be used on non-keyed SAMPLE BY queries (queries with no grouping columns other than the timestamp).
`FROM-TO` works with both non-keyed and keyed `SAMPLE BY` queries. Keyed queries emit one row per (bucket, key) combination across the full interval. Keyed `FROM-TO` requires `FROM`/`TO` to be constants; bind variables, function calls, or arithmetic expressions are rejected with _FROM-TO intervals are not supported for keyed SAMPLE BY queries_.
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.

I think there is some punctuation problem here. I am not sure which the restrictions are

Copy link
Copy Markdown
Contributor Author

@jovfer jovfer May 8, 2026

Choose a reason for hiding this comment

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

it's poor formatting, anyway I'll delete the 3rd sentence here to avoid duplication with limitation sections as suggested below.

Copy link
Copy Markdown
Collaborator

@javier javier left a comment

Choose a reason for hiding this comment

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

Small comments, but otherwise ready to go

- Only works with `ALIGN TO CALENDAR` (default alignment).
- Does not consider any specified `OFFSET`.
- Only for non-keyed `SAMPLE BY` (designated timestamp and aggregate columns only). See [Fill keyed queries with arbitrary intervals](/docs/cookbook/sql/time-series/fill-keyed-arbitrary-interval/) for a workaround.
- Keyed `FROM-TO` requires `FROM`/`TO` to be constants. Bind variables,
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.

This is exactly the same we said above. I would keept it here under limitations, and would remove from aboive

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.

2 participants