diff --git a/public/app/features/expressions/components/Reduce.tsx b/public/app/features/expressions/components/Reduce.tsx index dfedab25f86..6793b32af50 100644 --- a/public/app/features/expressions/components/Reduce.tsx +++ b/public/app/features/expressions/components/Reduce.tsx @@ -1,7 +1,8 @@ import * as React from 'react'; import { SelectableValue } from '@grafana/data'; -import { InlineField, InlineFieldRow, Input, Select } from '@grafana/ui'; +import { InlineField, InlineFieldRow, Input, Select, Alert } from '@grafana/ui'; +import { Trans, t } from 'app/core/internationalization'; import { ExpressionQuery, ExpressionQuerySettings, ReducerMode, reducerModes, reducerTypes } from '../types'; @@ -30,6 +31,10 @@ export const Reduce = ({ labelWidth = 'auto', onChange, refIds, query }: Props) const onModeChanged = (value: SelectableValue) => { let newSettings: ExpressionQuerySettings; switch (value.value) { + case ReducerMode.Strict: + newSettings = { mode: ReducerMode.Strict }; + break; + case ReducerMode.ReplaceNonNumbers: let replaceWithNumber = 0; if (query.settings?.mode === ReducerMode.ReplaceNonNumbers) { @@ -40,6 +45,7 @@ export const Reduce = ({ labelWidth = 'auto', onChange, refIds, query }: Props) replaceWithValue: replaceWithNumber, }; break; + default: newSettings = { mode: value.value, @@ -66,8 +72,30 @@ export const Reduce = ({ labelWidth = 'auto', onChange, refIds, query }: Props) ); }; + const strictModeNotification = () => { + if (mode !== ReducerMode.Strict) { + return null; + } + return ( + + + When Reduce Strict mode is used, the fill(null) function (InfluxQL) will result in{' '} + NaN.{' '} + + See the documentation for more details. + + + + ); + }; + return ( <> + {strictModeNotification()}