From 727e4a9616a2e19866f6537102890118d9c586e9 Mon Sep 17 00:00:00 2001 From: Nick Woolmer <29717167+nwoolmer@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:47:18 +0100 Subject: [PATCH] Small updates, railroad TBA --- reference/sql/sample-by.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/reference/sql/sample-by.md b/reference/sql/sample-by.md index dad98ff0..1a167d4b 100644 --- a/reference/sql/sample-by.md +++ b/reference/sql/sample-by.md @@ -76,9 +76,11 @@ When using `SAMPLE BY` with `FILL`, missing rows within the result set can be fi However, this will only fill rows between existing data in the data set, and cannot be used to fill rows outside of this range. +To fill outside the bounds of the existing data, you can specify a fill range using a `FROM-TO` clause. + #### Syntax -The resulting shape of the query can be specified using `FROM` and `TO`: +The resulting shape of the query is specified using `FROM` and `TO`: ```questdb-sql title='Pre-filling trip data' demo SELECT pickup_datetime as t, count @@ -91,7 +93,8 @@ Since there are no rows prior to 2009, these rows are filled automatically. This is distinct from the `WHERE` clause with a simple rule of thumb - `WHERE` controls what data flows in, `FROM-TO` controls what data flows out. -Both `FROM` and `TO` can be used in isolation to solely prefill or postfill data. +Both `FROM` and `TO` can be used in isolation to solely pre-fill or post-fill data. If `FROM` is not provided, +then the lower bound is the start of the dataset, aligned to calendar, and vice versa when `TO` is omitted. #### `WHERE` clause optimisation @@ -100,7 +103,7 @@ QuestDB will add one for you, matching the `FROM-TO` interval. This means that the query will run optimally, and avoid touching data not relevant to the result. -Therefore, the prior query will be compiled into something equivalent to this: +Therefore, the prior query will be compiled into something similar to this: ```questdb-sql title='Pre-filling trip data with WHERE optimisation' demo SELECT pickup_datetime as t, count @@ -117,7 +120,7 @@ Here are the current limits to this feature. - This syntax is not compatible with `FILL(PREV)` or `FILL(LINEAR)`. - This syntax is for `ALIGN TO CALENDAR` only (default alignment). - Any specified `OFFSET` will not be considered. -- This syntax is for non-keyed `SAMPLE BY` i.e only designated timestamp and aggregate columns. +- This syntax is for non-keyed `SAMPLE BY` i.e. only designated timestamp and aggregate columns. ## Fill options