Hi,
I've run into a roadblock with cogrouping. I have two separate streams in my SAQL I am trying to piece back together:
q = load "MyDataset";
r = filter q by 'SomeField' == "True";
r = foreach r generate 'FieldA' as 'FieldA', 'FieldB' as 'FieldB';
s = filter q by 'SomeOtherField' == "True";
s = foreach s generate 'FieldA' as 'FieldA', 'FieldC' as 'FieldC';
t = cogroup r by 'FieldA' left, s by 'FieldA';
t = foreach t generate r.'FieldA' as 'FieldA', r."FieldB' as 'FieldB', s.'FieldC' as 'FieldC';
I get 'FieldA' working as expected, but the inclusion of 'FieldB' and 'FieldC' causes an error (it says make sure the field 'FieldB/C' exists and is spelled correctly as if it is not there). Using an aggregation function, however, works - but I do not want to aggregate values. How do I correctly join these two streams and keep the granular level of data in the other fields?
Hello @Dvin Badalzadeh You may see if the approach below meets your needs:
q = load "MyDataset";
r = filter q by 'SomeField' == "True";
r = foreach r generate 'FieldA' as 'FieldA', 'FieldB' as 'FieldB';
r = group r by ('FieldA', 'FieldB');
s = filter q by 'SomeOtherField' == "True";
s = foreach s generate 'FieldA' as 'FieldA', 'FieldC' as 'FieldC';
s = group s by ('FieldA', 'FieldC');
t = cogroup r by 'FieldA' left, s by 'FieldA';
t = foreach t generate r.'FieldA' as 'FieldA', r."FieldB' as 'FieldB', s.'FieldC' as 'FieldC';
Attribution: The answer at
https://salesforce.stackexchange.com/questions/298871/monday-morning-challenge-join-two-data-streams-with-saql-in-salesforce-einstein