Support fills for SAMPLE BY FROM-TO with empty record sets
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.3k
- Forks
- 1.6k
- Avg merge
- 5d 10h
- Merged PRs (30d)
- 28
Description
Is your feature request related to a problem?
The SAMPLE BY FROM-TO feature added support for pre and post filling result sets, around existing records.
It also added support for fills with parallel sample by.
However, using the fill with no present records is not well supported.
Technically, it works with parallel sample by. Here's an example on demo:
select pickup_datetime, count() from trips
sample by 1M from '2030-01-01' to '2031-01-01' fill(null)
However, a version of this query runing with a sequential sample by will return nothing:
select pickup_datetime, count() from trips
sample by 1M from '2030-01-01' to '2031-01-01' fill(null)
align to calendar with offset '10:00'
This is because initTimestamps() and SampleByFillValueNotKeyedRecordCursor are short-circuit in the zero records case, and were not designed to return anything.
Describe the solution you'd like.
Ideally, we should support it for both the parallel and sequential cases, as a convenience syntax for generating timestamps.
Describe alternatives you've considered.
Using timestamp_sequence() i.e
select x, timestamp_floor('1d', timestamp_sequence(systimestamp(), 86400 * 1000000L))
from long_sequence(3)
This doesn't make it easy to handle calendar aligned cases.
Full Name:
Nick Woolmer
Affiliation:
QuestDB
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing initTimestamps() and SampleByFillValueNotKeyedRecordCursor, which the issue identifies as short-circuiting when there are no records. Reproduce the parallel and sequential SAMPLE BY FROM-TO queries with empty record ranges, then verify that both return the requested filled timestamps, including calendar alignment with an offset.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100