Merge pull request #50261 from ClickHouse/fix-doc-with-fill-by-sorting-prefix

Fixes for WITH FILL grouped by sorting prefix
This commit is contained in:
Ilya Yatsishin 2023-05-26 14:03:52 +02:00 committed by GitHub
commit 3635a7bf5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -544,10 +544,10 @@ Result:
└─────┴──────────┴───────┘
```
##Filling grouped by sorting prefix
## Filling grouped by sorting prefix
It can be useful to fill rows which have the same values in particular columns independently, - a good example is filling missing values in time series.
Assume there is the following time series table
Assume there is the following time series table:
``` sql
CREATE TABLE timeseries
(
@ -567,7 +567,7 @@ SELECT * FROM timeseries;
└───────────┴─────────────────────────┴───────┘
```
And we'd like to fill missing values for each sensor independently with 1 second interval.
The way to achieve it is to use `sensor_id` column as sorting prefix for filling column `timestamp`
The way to achieve it is to use `sensor_id` column as sorting prefix for filling column `timestamp`:
```
SELECT *
FROM timeseries
@ -589,7 +589,7 @@ INTERPOLATE ( value AS 9999 )
│ 432 │ 2021-12-01 00:00:05.000 │ 5 │
└───────────┴─────────────────────────┴───────┘
```
Here, the `value` column was interpolated with `9999` just to make filled rows more noticeable
Here, the `value` column was interpolated with `9999` just to make filled rows more noticeable.
This behavior is controlled by setting `use_with_fill_by_sorting_prefix` (enabled by default)
## Related content