Shift the evaluation of a metric to a specific period in the past


#1

I’m trying to define a baseline metric which is basically the evaluation of a regular metric but during a specific time, in my case my baseline period is 2016 July 1s to 2017 June 30th.

I’m experimenting with the window expression function like the following:

{
        "id" : "BaselineEnergyConsumption",
        "name": "BaselineEnergyConsumption",
        "description": "Baseline Billed consumption",
        "expression" : "window('MAX', BilledEnergyConsumption, (2016-year(now()))*12, 1)",
        "unit" : {
            "id" : "million_BTU"
        }
}

When I try to evaluate this metric I get following error:

Unexpected error during dispatching action through annotated claim: java.lang.NoSuchMethodError: c3.love.expr.bytecode.OperatorLib.sub(Ljava/lang/Double;Ljava/lang/Integer;)Ljava/lang/Double;

Obviously the simple solution will be to have variable passed to the window function to shift the evaluation but then I am looking for a way to do the calculation of the amount of shift directly in the expression.

Any hints how to achieve this?


#2

@bachr this should be supported and due to the current nature of the compiled expression engine we need a definition for

c3.love.expr.bytecode.OperatorLib.sub(Ljava/lang/Double;Ljava/lang/Integer;)Ljava/lang/Double;

As a work around can you try:
number(2016) - number(year(now()))


#3

thanks @rohit.sureka for the hint, but it seems it’s not helping. When using

"expression" : "window('MAX', BilledEnergyConsumption, (number(2016) - number(year(now())))*12, 12)"

I get the following error:

Bad type on operand stack
Exception Details:
  Location:
    c3/love/expr/bytecode/Expr_8282604774886819409_6339160018339046102.eval(Lc3/love/typesys/Obj;Lc3/love/timeseries/TimeInfo;)Ljava/lang/Object; @17: invokestatic
 Reason:
    Type 'java/lang/Number' (current frame, stack[2]) is not assignable to 'java/math/BigDecimal'
  Current Frame:
    bci: @17
    flags: { }
    locals: { 'c3/love/expr/bytecode/Expr_8282604774886819409_6339160018339046102', 'c3/love/typesys/Obj', 'c3/love/timeseries/TimeInfo' }
    stack: { 'c3/love/expr/bytecode/Expr_8282604774886819409_6339160018339046102', 'java/lang/Number', 'java/lang/Number' }
  Bytecode:
    0x0000000: 2a2a b400 34b8 003e b800 42b8 0046 b800\n    0x0000010: 3eb8 004c 2ab4 0031 b800 502a b600 52b0\n    0x0000020:                                        \n"

 

#4

@bachr please file a ticket, this should be a quick fix