All Implemented Interfaces:
NamedWriteable, Writeable, Resolvable, EvaluatorMapper, ConvertFunction

public class ToGauge extends AbstractConvertFunction
Converts a counter-typed value to its plain numeric (gauge) equivalent. The output type depends on the input: counter_long becomes long, counter_integer becomes integer, and counter_double becomes double. Plain numeric inputs are returned unchanged (idempotent). aggregate_metric_double inputs are also returned unchanged (idempotent). No values are modified; this is a pure type-annotation change.
  • Field Details

  • Constructor Details

  • Method Details

    • getWriteableName

      public String getWriteableName()
    • factories

      Description copied from class: AbstractConvertFunction
      A map from input type to ExpressionEvaluator ctor. Usually implemented like:
      
           private static final Map<DataType, BuildFactory> EVALUATORS = Map.ofEntries(
               Map.entry(BOOLEAN, (field, source) -> field),
               Map.entry(KEYWORD, ToBooleanFromStringEvaluator.Factory::new),
               ...
           );
      
           @Override
           protected Map<DataType, BuildFactory> factories() {
               return EVALUATORS;
           }
       
      Specified by:
      factories in class AbstractConvertFunction
    • dataType

      public DataType dataType()
      Returns the plain numeric variant of the input type: counter_long→long, etc. Plain numeric inputs pass through unchanged. Returns the input type unchanged when it is not yet resolved or has no counter variant to strip (DataType.noCounter() default branch).
      Overrides:
      dataType in class UnaryScalarFunction
    • isNoOpOnAllUnionTypes

      public static boolean isNoOpOnAllUnionTypes(TypeConflictedField tcf)
      Returns true when TO_GAUGE would be a no-op on every branch of a union field — every mapped type is already a non-counter type (including DataType.AGGREGATE_METRIC_DOUBLE).
    • replaceChildren

      public Expression replaceChildren(List<Expression> newChildren)
      Specified by:
      replaceChildren in class Node<Expression>
    • info

      protected NodeInfo<? extends Expression> info()
      Description copied from class: Node
      Normally, you want to use one of the static create methods to implement this.

      For QueryPlans, it is very important that the properties contain all of the expressions and references relevant to this node, and that all the properties are used in the provided constructor; otherwise query plan transformations like QueryPlan#transformExpressionsOnly(Function) will not have an effect.

      Specified by:
      info in class Node<Expression>