Last active
November 12, 2015 02:12
-
-
Save mwinkle/eeb4a5974d2aa2647099 to your computer and use it in GitHub Desktop.
An example of using F# to implement a U-SQL UDO (in this case, a processor).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sample U-SQL UDO (Processor) written in F# | |
// Note, currently (11/2015) requires deployment of F#.Core | |
namespace fSharpProcessor | |
open Microsoft.Analytics.Interfaces | |
type myProcessor() = | |
inherit IProcessor() | |
let CountryTranslation = dict [ "Deutschland", "Germany"; | |
"Schwiiz", "Switzerland"; | |
"UK", "United Kingdom"; | |
"USA", "United States of America"; | |
"中国", "PR China"; ] | |
override this.Process(row, output) = | |
let UserId = row.Get("UserId") | |
let Name = row.Get("Name") | |
let Address = row.Get("Address") | |
let City = row.Get("City") | |
let State = row.Get("State") | |
let PostalCode = row.Get("PostalCode") | |
let Country1 = row.Get("Country") | |
let Country = if CountryTranslation.ContainsKey(Country1) then CountryTranslation.[Country1] else Country1 | |
let Phone = row.Get("Phone") | |
output.Set(0, UserId) | |
output.Set(1, Name) | |
output.Set(2, Address) | |
output.Set(3, City) | |
output.Set(4, State) | |
output.Set(5, PostalCode) | |
output.Set(6, Country) | |
output.Set(7, Phone) | |
output.AsReadOnly() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's yet another example, that uses a hypothetical USQL Type Provider. This would parse the USQL file and provide bespoke parsing methods for that file.