Skip to content

Instantly share code, notes, and snippets.

@rjurney
Created February 2, 2012 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjurney/1722017 to your computer and use it in GitHub Desktop.
Save rjurney/1722017 to your computer and use it in GitHub Desktop.
A macro to generate pairs of people linked by email communications, given an email that links them
/* Filter emails according to existence of header pairs, from and [to, cc, bcc]
project the pairs (may be more than one to/cc/bcc), then emit them, lowercased. */
DEFINE header_pairs(email, col1, col2) RETURNS pairs {
filtered = FILTER $email BY ($col1 IS NOT NULL) AND ($col2 IS NOT NULL);
flat = FOREACH filtered GENERATE FLATTEN($col1) AS $col1, FLATTEN($col2) AS $col2;
$pairs = FOREACH flat GENERATE LOWER($col1), LOWER($col2);
}
pairs = header_pairs(email)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment