How is “=default” different from “{}” for default constructor and destructor?

This is a completely different question when asking about constructors than destructors. If your destructor is virtual, then the difference is negligible, as Howard pointed out. However, if your destructor was non-virtual, it’s a completely different story. The same is true of constructors. Using = default syntax for special member functions (default constructor, copy/move constructors/assignment, … Read more

How to define and use a User-Defined Aggregate Function in Spark SQL?

Supported methods Spark >= 3.0 Scala UserDefinedAggregateFunction is being deprecated (SPARK-30423 Deprecate UserDefinedAggregateFunction) in favor of registered Aggregator. Spark >= 2.3 Vectorized udf (Python only): from pyspark.sql.functions import pandas_udf from pyspark.sql.functions import PandasUDFType from pyspark.sql.types import * import pandas as pd df = sc.parallelize([ (“a”, 0), (“a”, 1), (“b”, 30), (“b”, -50) ]).toDF([“group”, “power”]) def … Read more

TEXTJOIN for xl2010/xl2013 with criteria

This TextJoinIfs user-defined-function (aka UDF) provides basic TEXTJOIN functionality to Excel 2003 – 2013 versions as well as expanded functionality for all versions by adding optional error control, uniqueness, sorting and a paramarray of conditions for easy criteria. This TextJoinIfs UDF code belongs in a public module code sheet; e.g. Book1 – Module1 (code). Option … Read more

Spark functions vs UDF performance?

when would a udf be faster If you ask about Python UDF the answer is probably never*. Since SQL functions are relatively simple and are not designed for complex tasks it is pretty much impossible compensate the cost of repeated serialization, deserialization and data movement between Python interpreter and JVM. Does anyone know why this … Read more

How to strip all non-alphabetic characters from string in SQL Server?

Try this function: Create Function [dbo].[RemoveNonAlphaCharacters](@Temp VarChar(1000)) Returns VarChar(1000) AS Begin Declare @KeepValues as varchar(50) Set @KeepValues=”%[^a-z]%” While PatIndex(@KeepValues, @Temp) > 0 Set @Temp = Stuff(@Temp, PatIndex(@KeepValues, @Temp), 1, ”) Return @Temp End Call it like this: Select dbo.RemoveNonAlphaCharacters(‘abc1234def5678ghi90jkl’) Once you understand the code, you should see that it is relatively simple to change it … Read more