/// <summary> /// Register UDF with no input argument, e.g: /// SqlContext.RegisterFunction<bool>("MyFilter", () => true); /// sqlContext.Sql("SELECT * FROM MyTable where MyFilter()"); /// </summary> /// <typeparam name="RT"></typeparam> /// <param name="name"></param> /// <param name="f"></param> public void RegisterFunction <RT>(string name, Func <RT> f) { logger.LogInfo("Name of the function to register {0}, method info", name, f.Method); Func <int, IEnumerable <dynamic>, IEnumerable <dynamic> > udfHelper = new UdfHelper <RT>(f).Execute; sqlContextProxy.RegisterFunction(name, SparkContext.BuildCommand(new CSharpWorkerFunc(udfHelper), SerializedMode.Row, SerializedMode.Row), Functions.GetReturnType(typeof(RT))); }
/// <summary> /// Register UDF with no input argument, e.g: /// sqlContext.RegisterFunction<bool>("MyFilter", () => true); /// sqlContext.Sql("SELECT * FROM MyTable where MyFilter()"); /// </summary> /// <typeparam name="RT"></typeparam> /// <param name="name"></param> /// <param name="f"></param> public void RegisterFunction <RT>(string name, Func <RT> f) { Func <int, IEnumerable <dynamic>, IEnumerable <dynamic> > udfHelper = new UdfHelper <RT>(f).Execute; sqlContextProxy.RegisterFunction(name, SparkContext.BuildCommand(udfHelper, SerializedMode.Row, SerializedMode.Row), Functions.GetReturnType(typeof(RT))); }
public void RegisterFunction(string name, byte[] command, string returnType) { sqlContextProxy.RegisterFunction(name, command, returnType); }