How to skip a filter depending on parameter value

local function map_profile(record)
  -- Add username and password to returned map.
  -- Could add other record bins here as well.
  return map {cdte=record.cdte,
sts=record.sts,
oid=record.oid,
typ=record.typ,
cnvpxurl=record.cnvpxurl,
offerconversionpixel=record.offerconversionpixel,
id=record.id,
glid=record.glid,
afid=record.afid

}

end



function check_offer_conversion(stream,oid,afid,gid)
  local function filter_oid(record)
    return record.oid == oid
  end
  local function filter_afid(record)
    return  record.afid==afid
  end
 local function filter_gid(record)
    return  record.gid==gid
  end
  return stream : filter(filter_oid):filter(filter_afid):filter(filter_gid):map(map_profile)
end

I want the filter_glid to skip if value of oid == 0. Please tell me the changes in the above lua.

what do you mean by “skip”? let the record pass thru? then just build that logic in glid filter. if … then else …

yes i want to skip the filter_glid local function based on oid value

Did you try something like this?

local function filter_gid(record)
    if oid == 0 then
     return true
   else
    return  record.gid==gid
  end
1 Like