Questions tagged [user-defined-functions]

A function provided by the user of a program or an environment most often for spreadsheet type applications or database applications. Use [custom-functions-excel] for Excel and [custom-function] for Google sheets. Specify a programming language tag as well: [google-apps-script], [javascript], [sql], [tsql], etc. as well as a tag for the application: [excel], [google-spreadsheet], [sql-server] etc.

In the context of a programming language or an environment, a User Defined Function (UDF) is a function that is created by a user to perform a specific task (as opposed to a function that is intrinsic to the environment, built into the programming language or environment).

Spreadsheet applications like Excel and Google Sheets calls these "custom functions".

Microsoft also uses the term User Defined Functions with . The tag may also be applicable. See What is the need for user-defined functions in SQL Server?

Use:

4875 questions
1
vote
2 answers

Why the VBA UDF "Range.Formula =" don't work?

I want to copy the formula from one cell/cells to another cell/cells by Range.Formula = . But it not work as expected. If I run the VBA step by step, the function will ended at Range.Formula = without error. Function test1(sOURCE As Range, tARGET…
xxing01
  • 13
  • 4
1
vote
1 answer

Scala explode followed by UDF on a dataframe fails

I have a scala dataframe with the following schema: root |-- time: string (nullable = true) |-- itemId: string (nullable = true) |-- itemFeatures: map (nullable = true) | |-- key: string | |-- value: string (valueContainsNull = true) I…
Callie
  • 11
  • 1
1
vote
1 answer

Spark: Using a UDF to create an Array column in a Dataframe

I have a simple function that takes some XML in a field, parses the values, and returns a list: becomes a nested list [[1,2,3],[2,3,2]] I've made this a udf, and I'm making…
1
vote
3 answers

What does "Microsoft Office Excel is waiting for another application to complete an OLE action." mean?

I have a working RTD Excel automation add-in similar to the one described here. Intermittently, while attempting to load a sheet that includes this formula I get the following error: Microsoft Office Excel is waiting for another application to…
Frank
  • 3,029
  • 5
  • 34
  • 43
1
vote
2 answers

Select values from MapType Column in UDF PySpark

I am trying to extract the value from the MapType column in PySpark dataframe in the UDF function. Below is the PySpark dataframe: +-----------+------------+-------------+ |CUSTOMER_ID|col_a |col_b …
1
vote
0 answers

How does performance differ between a volatile Excel function and a VBA UDF that uses evaluate() on it?

I have an unusual use case -- we have a table of calculation rules and another table that looks up that table in order to make calculations. So we do an XLOOKUP that returns a formula, and then we execute the formula. For example, I have a VBA UDF…
not rob
  • 11
  • 1
1
vote
0 answers

how to replace null value from database with another string value present in same column columns in python?

Here We have one data frame Which contains avengers hero names, and key columns in a data frame. There are some rows that have a null name but the same name has a primary key assigned. I need to fill the Blanks with the key value if it is blank in…
1
vote
2 answers

Vectorized pandas udf in pyspark with dict lookup

I'm trying to learn to use pandas_udf in pyspark (Databricks). One of the assignments is to write a pandas_udf to sort by day of the week. I know how to do this using spark udf: from pyspark.sql.functions import * data = [('Sun', 282905.5), ('Mon',…
Kashyap
  • 15,354
  • 13
  • 64
  • 103
1
vote
1 answer

How to intersect rows containing an array for a dataframe in pyspark

I have a dataframe df = spark.createDataFrame( [(2022, 1, 3, '01', ['apple', 'banana', 'orange'], [['apple', 'edible', 'fruit', 'green'], ['largest', 'herbaceous', 'flowering', 'plant', 'Vitamin B', 'fruit'], ['source', 'Vitamin…
Rory
  • 471
  • 2
  • 11
1
vote
3 answers

Reusing Case Statement for many Columns in same SELECT statement

I have a big table from a survey where all the answers are similar but I need to make them consistent. I need to reuse the same case statement for all the columns, however that would lead to a very ugly and long query. Is there a way to make a case…
1
vote
1 answer

Stored procedure table-valued variable without aliases in query string must declare scalar variable

I will pass a table-valued input parameter into a stored procedure, and also a variable that contains query string, so I made my sproc like this. CREATE PROCEDURE [dbo].[SP_SelectData_View] ( @Sort VARCHAR(MAX), @CONDITION VARCHAR(MAX) = '' …
1
vote
1 answer

How to use apply() on a user defined function in r - error saying it's not a function

I've written a function that calculates the density of a bivariate normal distribution using the width and length of flowers. I want to apply the function to a data frame to calculate the density for each row. I'm trying to use the apply() function…
Becca
  • 59
  • 1
  • 4
1
vote
1 answer

How to transform a data which is list of dictionaries to a dictionary of dictionaries with key being one of the value in inner dicts in Snowflake

How to transform a data which is list of dictionaries to a dictionary of dictionaries with key being one of the value in inner dicts in Snowflake. Context: The values I want to transform are in a cell of a table, i am trying to replace that cell…
1
vote
0 answers

spark scala filter array of strings column with list of strings very slow performance

I have an ArrayType[StringType] column (col1). I want to filter each array in the column using list of string of length ~100k strings so I create col2 of StringType. My current solution is very slow. How can I speed it up? val dict: Seq[String] //…
1
vote
0 answers

Data Bricks read RDD

I need to read a CSV file as an RDD and then extract the desired data using functions, the issue is the first function cannot produce proper RDD for the second function. this my code: def extract_vin_key_value(line): sr=line.split(',') if…
Naser
  • 13
  • 2