Ejemplo n.º 1
0
        /// <summary>
        /// Register UDF with no input argument, e.g:
        ///     SqlContext.RegisterFunction&lt;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)));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Register UDF with no input argument, e.g:
        ///     sqlContext.RegisterFunction&lt;bool&gt;("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)));
        }
Ejemplo n.º 3
0
 public void RegisterFunction(string name, byte[] command, string returnType)
 {
     sqlContextProxy.RegisterFunction(name, command, returnType);
 }