Skip to content

Commit

Permalink
fix: vector function for PromQL need to ignore the time index also close
Browse files Browse the repository at this point in the history
 #5392

Signed-off-by: yihong0618 <[email protected]>
  • Loading branch information
yihong0618 committed Jan 19, 2025
1 parent c78a492 commit 834ae3e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/query/src/promql/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2014,9 +2014,12 @@ impl PromPlanner {
.collect::<Vec<_>>()
};

// push time index column if it exist
// push time index column if it exists
if let Some(time_index_column) = &self.ctx.time_index_column {
tag_columns.push(Column::from_name(time_index_column));
// issue #5392 if only_join_time_index is true, we don't need to push time_index_column to tag_columns
if !only_join_time_index {
tag_columns.push(Column::from_name(time_index_column));
}
}

let right = LogicalPlanBuilder::from(right)
Expand Down
17 changes: 17 additions & 0 deletions tests/cases/standalone/common/promql/set_operation.result
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,23 @@ tql eval (3000, 3000, '1s') http_requests AND IGNORING (g, instance, job) vector
| 1970-01-01T00:50:00 | app | 1 | production | 600.0 |
+---------------------+-----+----------+------------+----------------+

-- https://github.com/GreptimeTeam/greptimedb/issues/5392
-- SQLNESS SORT_RESULT 3 1
tql eval (3000, 3000, '1s') vector(1) * http_requests;

+-----+----------+------------+---------------------+------------------------------------------------+
| job | instance | g | ts | .greptime_value * http_requests.greptime_value |
+-----+----------+------------+---------------------+------------------------------------------------+
| api | 0 | canary | 1970-01-01T00:50:00 | 300.0 |
| api | 0 | production | 1970-01-01T00:50:00 | 100.0 |
| api | 1 | canary | 1970-01-01T00:50:00 | 400.0 |
| api | 1 | production | 1970-01-01T00:50:00 | 200.0 |
| app | 0 | canary | 1970-01-01T00:50:00 | 700.0 |
| app | 0 | production | 1970-01-01T00:50:00 | 500.0 |
| app | 1 | canary | 1970-01-01T00:50:00 | 800.0 |
| app | 1 | production | 1970-01-01T00:50:00 | 600.0 |
+-----+----------+------------+---------------------+------------------------------------------------+

drop table http_requests;

Affected Rows: 0
Expand Down
4 changes: 4 additions & 0 deletions tests/cases/standalone/common/promql/set_operation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ tql eval (3000, 3000, '1s') http_requests AND ON (dummy) vector(1);
-- SQLNESS SORT_RESULT 3 1
tql eval (3000, 3000, '1s') http_requests AND IGNORING (g, instance, job) vector(1);

-- https://github.com/GreptimeTeam/greptimedb/issues/5392
-- SQLNESS SORT_RESULT 3 1
tql eval (3000, 3000, '1s') vector(1) * http_requests;

drop table http_requests;

drop table cpu_count;
Expand Down

0 comments on commit 834ae3e

Please sign in to comment.