fix: vector function for PromQL need to ignore the time index also (#5398)

* fix: vector function for PromQL need to ignore the time index also close #5392

Signed-off-by: yihong0618 <zouzou0208@gmail.com>

* fix: do not affect scalar function

Signed-off-by: yihong0618 <zouzou0208@gmail.com>

* fix: betteer name for it

Signed-off-by: yihong0618 <zouzou0208@gmail.com>

---------

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
yihong
2025-01-22 10:51:12 +08:00
committed by GitHub
parent f74a955504
commit d2f3f2e24d
3 changed files with 32 additions and 2 deletions

View File

@@ -409,6 +409,10 @@ impl PromPlanner {
}
}
let mut field_columns = left_field_columns.iter().zip(right_field_columns.iter());
let has_special_vector_function = (left_field_columns.len() == 1
&& left_field_columns[0] == GREPTIME_VALUE)
|| (right_field_columns.len() == 1 && right_field_columns[0] == GREPTIME_VALUE);
let join_plan = self.join_on_non_field_columns(
left_input,
right_input,
@@ -417,6 +421,7 @@ impl PromPlanner {
// if left plan or right plan tag is empty, means case like `scalar(...) + host` or `host + scalar(...)`
// under this case we only join on time index
left_context.tag_columns.is_empty() || right_context.tag_columns.is_empty(),
has_special_vector_function,
)?;
let join_plan_schema = join_plan.schema().clone();
@@ -2003,6 +2008,7 @@ impl PromPlanner {
left_table_ref: TableReference,
right_table_ref: TableReference,
only_join_time_index: bool,
has_special_vector_function: bool,
) -> Result<LogicalPlan> {
let mut tag_columns = if only_join_time_index {
vec![]
@@ -2014,9 +2020,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 is special vector function
if !has_special_vector_function {
tag_columns.push(Column::from_name(time_index_column));
}
}
let right = LogicalPlanBuilder::from(right)