mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-19 06:20:38 +00:00
@@ -515,6 +515,13 @@ impl FlatRowGroupLastRowReader {
|
||||
if self.yielded_batches.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Filtered flat last-row scans only contain the subset of series that matched the
|
||||
// encoded primary-key prefilter, so they cannot be published under the shared
|
||||
// selector cache key.
|
||||
if self.primary_key_filter.is_some() {
|
||||
return;
|
||||
}
|
||||
let batches = std::mem::take(&mut self.yielded_batches);
|
||||
let value = Arc::new(SelectorResultValue::new_flat(
|
||||
batches,
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
CREATE TABLE last_row_selector_cache_filter (
|
||||
host STRING,
|
||||
cpu DOUBLE,
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
PRIMARY KEY (host)
|
||||
) WITH ('sst_format' = 'flat');
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO last_row_selector_cache_filter VALUES
|
||||
('a', 1.0, 1000),
|
||||
('a', 2.0, 2000),
|
||||
('b', 3.0, 1000),
|
||||
('b', 4.0, 2000);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
ADMIN FLUSH_TABLE('last_row_selector_cache_filter');
|
||||
|
||||
+-----------------------------------------------------+
|
||||
| ADMIN FLUSH_TABLE('last_row_selector_cache_filter') |
|
||||
+-----------------------------------------------------+
|
||||
| 0 |
|
||||
+-----------------------------------------------------+
|
||||
|
||||
SELECT host, last_value(cpu ORDER BY ts) AS last_cpu
|
||||
FROM last_row_selector_cache_filter
|
||||
WHERE host = 'a'
|
||||
GROUP BY host
|
||||
ORDER BY host;
|
||||
|
||||
+------+----------+
|
||||
| host | last_cpu |
|
||||
+------+----------+
|
||||
| a | 2.0 |
|
||||
+------+----------+
|
||||
|
||||
SELECT host, last_value(cpu ORDER BY ts) AS last_cpu
|
||||
FROM last_row_selector_cache_filter
|
||||
GROUP BY host
|
||||
ORDER BY host;
|
||||
|
||||
+------+----------+
|
||||
| host | last_cpu |
|
||||
+------+----------+
|
||||
| a | 2.0 |
|
||||
| b | 4.0 |
|
||||
+------+----------+
|
||||
|
||||
DROP TABLE last_row_selector_cache_filter;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
CREATE TABLE last_row_selector_cache_filter (
|
||||
host STRING,
|
||||
cpu DOUBLE,
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
PRIMARY KEY (host)
|
||||
) WITH ('sst_format' = 'flat');
|
||||
|
||||
INSERT INTO last_row_selector_cache_filter VALUES
|
||||
('a', 1.0, 1000),
|
||||
('a', 2.0, 2000),
|
||||
('b', 3.0, 1000),
|
||||
('b', 4.0, 2000);
|
||||
|
||||
ADMIN FLUSH_TABLE('last_row_selector_cache_filter');
|
||||
|
||||
SELECT host, last_value(cpu ORDER BY ts) AS last_cpu
|
||||
FROM last_row_selector_cache_filter
|
||||
WHERE host = 'a'
|
||||
GROUP BY host
|
||||
ORDER BY host;
|
||||
|
||||
SELECT host, last_value(cpu ORDER BY ts) AS last_cpu
|
||||
FROM last_row_selector_cache_filter
|
||||
GROUP BY host
|
||||
ORDER BY host;
|
||||
|
||||
DROP TABLE last_row_selector_cache_filter;
|
||||
Reference in New Issue
Block a user