Exemplo n.º 1
0
        /// <summary>
        /// Register UDF with 3 input arguments, e.g:
        ///     SqlContext.RegisterFunction&lt;bool, string, string, string>("MyFilter", (arg1, arg2, arg3) => arg1 != null &amp;&amp; arg2 != null &amp;&amp; arg3 != null);
        ///     sqlContext.Sql("SELECT * FROM MyTable where MyFilter(columnName1, columnName2, columnName3)");
        /// </summary>
        /// <typeparam name="RT"></typeparam>
        /// <typeparam name="A1"></typeparam>
        /// <typeparam name="A2"></typeparam>
        /// <typeparam name="A3"></typeparam>
        /// <param name="name"></param>
        /// <param name="f"></param>
        public void RegisterFunction <RT, A1, A2, A3>(string name, Func <A1, A2, A3, 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, A1, A2, A3>(f).Execute;

            udfRegistrationProxy.RegisterFunction(name, SparkContext.BuildCommand(new CSharpWorkerFunc(udfHelper), SerializedMode.Row, SerializedMode.Row), Functions.GetReturnType(typeof(RT)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Register UDF with 10 input arguments, e.g:
        ///     sqlContext.RegisterFunction&lt;bool, string, string, ..., string&gt;("MyFilter", (arg1, arg2, ..., arg10) => arg1 != null && arg2 != null && ... && arg10 != null);
        ///     sqlContext.Sql("SELECT * FROM MyTable where MyFilter(columnName1, columnName2, ..., columnName10)");
        /// </summary>
        /// <typeparam name="RT"></typeparam>
        /// <typeparam name="A1"></typeparam>
        /// <typeparam name="A2"></typeparam>
        /// <typeparam name="A3"></typeparam>
        /// <typeparam name="A4"></typeparam>
        /// <typeparam name="A5"></typeparam>
        /// <typeparam name="A6"></typeparam>
        /// <typeparam name="A7"></typeparam>
        /// <typeparam name="A8"></typeparam>
        /// <typeparam name="A9"></typeparam>
        /// <typeparam name="A10"></typeparam>
        /// <param name="name"></param>
        /// <param name="f"></param>
        public void RegisterFunction <RT, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>(string name, Func <A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, RT> f)
        {
            Func <int, IEnumerable <dynamic>, IEnumerable <dynamic> > udfHelper = new UdfHelper <RT, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>(f).Execute;

            sqlContextProxy.RegisterFunction(name, SparkContext.BuildCommand(udfHelper, SerializedMode.Row, SerializedMode.Row), Functions.GetReturnType(typeof(RT)));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Register UDF with 2 input arguments, e.g:
        ///     sqlContext.RegisterFunction&lt;bool, string, string&gt;("MyFilter", (arg1, arg2) => arg1 != null && arg2 != null);
        ///     sqlContext.Sql("SELECT * FROM MyTable where MyFilter(columnName1, columnName2)");
        /// </summary>
        /// <typeparam name="RT"></typeparam>
        /// <typeparam name="A1"></typeparam>
        /// <typeparam name="A2"></typeparam>
        /// <param name="name"></param>
        /// <param name="f"></param>
        public void RegisterFunction <RT, A1, A2>(string name, Func <A1, A2, RT> f)
        {
            Func <int, IEnumerable <dynamic>, IEnumerable <dynamic> > udfHelper = new UdfHelper <RT, A1, A2>(f).Execute;

            sqlContextProxy.RegisterFunction(name, SparkContext.BuildCommand(new CSharpWorkerFunc(udfHelper), SerializedMode.Row, SerializedMode.Row), Functions.GetReturnType(typeof(RT)));
        }