/* Enter a unique ExecutionPlan */
@Plan:name('IsAnalytics-ExecutionPlan-IdPPropertiesUpdateData')

/* Enter a unique description for ExecutionPlan */
-- @Plan:description('ExecutionPlan')

/* define streams/tables and write queries here ... */

@Import('org.wso2.is.analytics.stream.IdPPropertiesUpdate:1.0.0')
define stream IdPPropertiesUpdateStream (meta_tenantId int, idPName string, tenantDomain string, idPProperties string, actionHolder string, actionTimestamp long);

@Export('org.wso2.is.analytics.stream.LatestIdPProperties:1.0.0')
define stream LatestIdPPropertiesStream (idPName string, tenantDomain string, propertyName string, propertyValue string);

from IdPPropertiesUpdateStream#isAnalytics:jsonFlatMapDuplicator(idPProperties)
select idPName, tenantDomain, key as propertyName, value as propertyValue
having not(propertyName is null)
insert into LatestIdPPropertiesStream;
