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
0 answers

WASM+UDF performance comparison in Scylladb, why there is no obvious differance?

I write an add function in wasm to test the performance of WASM in Scylladb, at the same time, I write the add function with lua to compare the performance. However, there is no obvious difference between the two languages compiled into UDF, this…
1
vote
1 answer

Is 100 a magic number for cardinality estimation of SELECT * FROM [Multi-Statement-Table-Valued-Function] queries?

I'm running on SQL Server 2019. Whenever I write a query of the form SELECT * FROM [Multi-Statement-Table-Valued-Function] the execution plan shows that it expected to get 100 rows from this process. Is this a consistent and documented pattern? Or…
1
vote
1 answer

CLR Table Valued Function Parameter Count for FillRow method error

I have a C# (.NET Framework 4.7.2) script to perform some custom reading of trace codes, which I am trying to use to make a SQL (V14.0.3445.2) Table Valued Function. The C# FillRow Method looks like this: public partial class UserDefinedFunctions { …
High Plains Grifter
  • 1,357
  • 1
  • 12
  • 36
1
vote
0 answers

PySpark not able to read dictionary

My questions could be complicated, but I can explain further if someone helps me in resolving. I'm writing a udf. I have a dictionary called _readingType={0:("a","b")} there are 300 keys in this dictionary. There is a variabale called reading =…
1
vote
1 answer

How to pass string and dictionary as arguments to vectorized Python UDF definition in Snowflake

I am trying to create a python vectorized udf to process columns in a table. I want to pass the column to be processed and 2 additional arguments to the udf, one arguments is a string and the other is a dictionary. The processing of the column…
cryp
  • 2,285
  • 3
  • 26
  • 33
1
vote
1 answer

Is there a way to make a UDF in Snowflake sleep for a certain amount of time before it returns

I am trying to write a snowflake UDF that sleeps for 60 seconds and then runs. Is this possible to define within a UDF? Something like CREATE OR REPLACE FUNCTION MY_FUNCTION() RETURNS INT AS $$ --- sleeps for 60 seconds --- executes function/does…
1
vote
2 answers

Use map function to create multiple plots in R

I am interested in creating plots exploring a range of variables in columns within a dataframe. So far, I have a function that successfully calls a plot, and now hoping to apply this in a tidyverse format with map. require(dplyr) library(purrr) #…
marcel
  • 389
  • 1
  • 8
  • 21
1
vote
1 answer

Do User-Defined Scalar Valued Functions still prevent parallelism?

I'm currently reading a book about SQL Server 2014. It claims that User-Defined Scalar Valued Functions prevent parallelism for the entire plan that they appear in. Is this still true in later versions?
J. Mini
  • 1,868
  • 1
  • 9
  • 38
1
vote
1 answer

How to use CHANGE_TRACKING_CURRENT_VERSION in a user defined function?

I am working on a project that uses Entity Framework and change tracking in SQL Server. I want to create a user defined function that returns the current version of the tracked changes in the database, so that I can use it in my queries with Entity…
1
vote
2 answers

How to convert two array columns into an array of structs based on array element positions in PySpark?

New to PySpark and need help with this problem I'm running into I have a dataframe that contains two columns as shown below: +------------------+--------------------+ | first_name | last_name …
1
vote
1 answer

Tune a SQL scalar function that does simple operations a lot of times

I have a column of data type image those values look similar to…
1
vote
1 answer

Define default value to arguments in Snowflake Function (UDF)

I want to create SQL function two params: CREATE OR REPLACE FUNCTION myudf (varchar_argument VARCHAR, number_argument NUMBER) ... But I want to set default value if the user did not specify all arguments while calling select * from…
1
vote
1 answer

INDEX MATCH to also pull through notes?

I'm looking up to a tab of data that has data ranging back for a couple of years. Much of the data also has notes attached to the cells. In my summary tab, which will be looking up a months worth of daily data, I need the notes attached to the…
Doom
  • 13
  • 2
1
vote
2 answers

Why I get a "Syntax error:L compilation error: (line ..." when trying to create a SNOWFLAKE UDTF which use IDENTIFIER function?

Why I get a "Syntax error:L compilation error: (line ..." when trying to create a Snowflake UDTF? If I comment the line: "AND IDENTIFIER(baseline) = I.COMP" the function compiles correctly but do not generate the expected results. SQL is the handler…
1
vote
2 answers

How to loop through an array from XLookup to return a specific value in VBA?

I'm working on a custom function and so far I was able to run a Xlookup within it in VBA. Now I want to return a specific array value from the xlookup based on certain criteria. I'm stuck on how to actually do this. The condition I want is if the…
Allen
  • 13
  • 3