I am trying to do an aggregation with Esper 8.8.0 EPL using the following code. When ProductEvent is published then I am trying to save it into a table after converting the complete ProductEvent bean object into json. Is there any way I can pass ProductEven Object itself in custom function when executing merge statement -
@public create table OutputTable
(
productId string primary key
, productName string
, productJson string
);
@name('stmtUpdateOutputTable') on ProductEvent pe
merge OutputTable ot
where ot.productId = pe.productId
when not matched
then insert select productId, productName, Utils.getJson(*)
when matched
then update
set
ot.productName= pe.productName,
ot.productJson = Utils.getJson(*)
;
ProductEvent is a java bean that contains more than 100 property so it is not a good idea I pass each individual field when call custom function -
public class ProductEvent{
private String productId;
private String productName;
private Double price;
private LocalDate firstAvailableDate;
//..... around 100 more properties here
}
Utils is a helper class that contains static method -
public static String getJson(ProductEvent event) {
return new ObjectMapper().writeValueAsString(event);
}
In the on-merge, there are two aliases: "pe" for ProductEvent and "ot" for OutputTable, so "...Utils.getJson(pe)...
" would work.