greptimedb icon indicating copy to clipboard operation
greptimedb copied to clipboard

PromQL queries with binary operators after an `or` operator result in error

Open dekelpilli opened this issue 1 year ago • 4 comments

What type of bug is this?

Unexpected error

What subsystems are affected?

Query Engine

Minimal reproduce step

On a metric with data in the given time range, execute

 {__name__="my_metric"} or {__name__="my_metric"} + 5

The actual query I want to run is

(delta({__name__="my_metric"}[1m] offset 15s) * 60) > 100
or 
({__name__="my_metric"} * 0)

As a way to default missing/filtered values to 0. Usually I would use ... or label_replace(vector(0), ...), but label_replace isn't supported yet.

What did you expect to see?

The left query values being ORed with 0

What did you see instead?

PlanQuery: Internal error during building DataFusion plan: No field named my_metric."greptime_value * Float64(0)". Valid fields are my_metric.my_tag, my_metric.greptime_timestamp, "greptime_value * Float64(0)".

What operating system did you use?

Mac OS 15.1

What version of GreptimeDB did you use?

0.11.0

Relevant log output and stack trace

No response

dekelpilli avatar Dec 12 '24 02:12 dekelpilli

Thanks for reporting this. It seems caused by column name mismatching, let me file a fix.

BTW, does this work for you as a workaround? (delta({__name__="my_metric"}[1m] offset 15s) * 60) > 100 or vector(0)

waynexia avatar Dec 12 '24 08:12 waynexia

Thanks for getting on that so quickly.

BTW, does this work for you as a workaround? (delta({name="my_metric"}[1m] offset 15s) * 60) > 100 or vector(0)

No, because we expect the delta portion to return a series (or multiple series) with labels, which then won't match the vector(0) portion. This is a workaround because label_replace isn't ready.

dekelpilli avatar Dec 12 '24 08:12 dekelpilli

I implemented the label_join and label_replace functions in #5153. Thank you for your report.

killme2008 avatar Dec 12 '24 14:12 killme2008

@waynexia Is this issue fixed?

killme2008 avatar Feb 08 '25 06:02 killme2008

Not sure if it is fixed @waynexia

killme2008 avatar Jul 11 '25 07:07 killme2008

I've verified on the latest v0.15.3 and it's fixed. Sorry for the late response

waynexia avatar Aug 03 '25 19:08 waynexia