Can't Access a Watcher Payload Object in Action Condition

I'm attempting to set up a condition for an action using an attribute of the current watch payload. The watch payload is defined as the following in a script transform:

return [
              'table': lessRows.stream().map(x -> {return [
                'table_name': x[0],
                'schema_name': x[1],
                'db_name': x[2],
                'cluster_name': x[3],
                'new_row_count': x[4],
                'old_row_count': x[5],
                'diff': x[6],
                'percent_change': x[7],
                'size': tableSize]}).collect(Collectors.toList())
            ]

where lessRows is a list object containing output information.

I'm trying to write a condition for an action to check if tableSize > 0. I've tried the following:

"condition": {
        "compare": {
          "ctx.payload.table.size": {
            "gt": 0
          }
        }
      }
"condition": {
        "script": {
          "source": "return ctx.payload.table.size > 0"
        }
      }
"condition": {
        "script": {
          "source": "return ctx.payload.table.stream().anyMatch(x -> x.size > 0)"
        }
      }

None have worked and I'm really not sure why. tableSize is declared as an int in the script transform so type shouldn't be an issue. And I am sure that tableSize is incremented accurately because when I output the ctx.payload.table object I get something like:

{0={cluster_name= anly_prod, new_row_count=18209133, db_name= anly_prod_db , size=1, diff=220972, schema_name= anly_prod , table_name=rtap_agg_pacing_health , percent_change=1.19, old_row_count=18430105}}

depending on what my input is.

So, any ideas as to why I can't compare the ctx.payload.table.size attribute would be very helpful. Thanks.

EDIT: Also tried:

"condition": {
    "script": {
      "source": "return ctx.payload.table.stream().anyMatch(x -> x.cluster_name.equals('anly_prod'))"
    }
  },

which did not work either, so I'm guessing it doesn't have to do with the tableSize variable.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.