user-defined-aggregate

SQLCLR custom aggregate with multiple sql_variant parameters

爷,独闯天下 提交于 2019-12-09 03:46:41
问题 Hy, I have post a question about CLR User-Defined Aggregates few month ago oon this post. This works like a charm. But now I would like to quite the same functions with the two parameters in sql_variant type. Like in my previous post, the two function would be sMax and sMin and will return the first value depending on the second. I found that the sql_variant type is a object type in C#. But I having difficulties to accumulate and compare the object. What is the best option to compare this two

Why Mutable map becomes immutable automatically in UserDefinedAggregateFunction(UDAF) in Spark

巧了我就是萌 提交于 2019-12-04 20:58:28
问题 I am trying to define a UserDefinedAggregateFunction(UDAF) in Spark, which counts the number of occurrences for each unique values in a column of a group. This is an example: Suppose I have a dataframe df like this, +----+----+ |col1|col2| +----+----+ | a| a1| | a| a1| | a| a2| | b| b1| | b| b2| | b| b3| | b| b1| | b| b1| +----+----+ I will have a UDAF DistinctValues val func = new DistinctValues Then I apply it to the dataframe df val agg_value = df.groupBy("col1").agg(func(col("col2")).as(

SQLCLR custom aggregate with multiple parameters

穿精又带淫゛_ 提交于 2019-12-02 17:16:27
问题 I have trouble understanding of how CLR User-Defined Aggregates work. I have to create some custom CLR aggregates with multiple parameters. The point is to get the value of the first parameter depending on the second. For example, I have the following values in my table, and I need the oldest employee Name for each Type : Type | Name | Age -------------------------------- Manager | emp 1 | 35 Manager | emp 2 | 42 Developer | emp 3 | 36 Developer | emp 4 | 45 Developer | emp 5 | 22 So I would

SQLCLR custom aggregate with multiple parameters

十年热恋 提交于 2019-12-02 08:31:16
I have trouble understanding of how CLR User-Defined Aggregates work. I have to create some custom CLR aggregates with multiple parameters. The point is to get the value of the first parameter depending on the second. For example, I have the following values in my table, and I need the oldest employee Name for each Type : Type | Name | Age -------------------------------- Manager | emp 1 | 35 Manager | emp 2 | 42 Developer | emp 3 | 36 Developer | emp 4 | 45 Developer | emp 5 | 22 So I would like to write a query like this to get the result by using my assembly: Select Type, dbo

SQLCLR custom aggregate with multiple sql_variant parameters

安稳与你 提交于 2019-12-02 04:33:07
Hy, I have post a question about CLR User-Defined Aggregates few month ago oon this post . This works like a charm. But now I would like to quite the same functions with the two parameters in sql_variant type. Like in my previous post, the two function would be sMax and sMin and will return the first value depending on the second. I found that the sql_variant type is a object type in C#. But I having difficulties to accumulate and compare the object. What is the best option to compare this two object without knowing the type? When using SQL_VARIANT / object , you can determine the type by