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
1 answer

Why doesn't this Python user-defined function do its task?

I created this function in Python to check the data type of each column of a DF and make sure it becomes the data type it's supposed to be. def dataType(df): '''This function makes sure the data type for all 7 columns of the final dataframe are…
Claie
  • 25
  • 5
1
vote
1 answer

Snowflake function how to input IN statment to function

I have function in Snowflake where I would like to input a variable there contains a IN statment for a query. It works when I only have one item: select * from table(my_function('62696')) But I can not figure out how to do when I have more items, I…
jvels
  • 319
  • 2
  • 16
1
vote
1 answer

Snowflake Javascript UDFs: Decimal values nested within objects emitted as scientific notation

It looks like Snowflake UDFs emit decimal values within object types (JSON structures) using scientific notation by default, even if the values don't have much precision or many significant digits. Is there a way to prevent this transformation, or…
1
vote
1 answer

Using schema-bound SQL Server user-defined functions with alias types?

Consider the following T-SQL statements: create type mytype from decimal(8,3) go create function f (@x int) returns mytype with schemabinding as begin return @x * @x end When I try this using SQL Server 2017 (v14.xx), I get this error: Msg…
1
vote
0 answers

Query with distinct keyword and subquery not working in Hive with udf

Not working Query : select lookup(city, state, tax,'addresslookup') from (select distinct city, state, tax from open_glory.addylookup) a Working Query (without distinct): select lookup(city, state, tax,'addresslookup') from (select city, state,…
1
vote
3 answers

SQL Server: create multiplication table

I need help regarding this problem. I need to create a function that will accept an integer and return a 10x10 multiplication table starting from the input value. Sample can be seen below. INPUT = 2 OUTPUT = 2 3 4 5 6 7 8 9 10 …
711721
  • 41
  • 1
  • 7
1
vote
1 answer

How to use ONNX models for inference in Spark

I have trained a model for text classification using huggingface/transformers, then I exported it using the built-in ONNX functionality. Now, I'd like to use it for inference on millions of texts (around 100 millions of sentences). My idea is to put…
Contestosis
  • 369
  • 1
  • 4
  • 19
1
vote
0 answers

Data bricks:- Cannot display the predicted output by using ml flow registered model

I have created a model using diabetes dataset for prediction. I have trained, evaluated, logged and registered it as a new model in ML flow. Now I am trying to load the registered model and trying to predict on new data. All though I was able to…
1
vote
1 answer

DB2 7.2 Java UDF not in Classpath

I've created a Java class implementing a Levenshtein Distance algorithm in Java in order to use it in a DB2 UDF. Apparently, under DB2, there are two ways of registering a java UDF, either by copying the .class file under…
Manu Andrei
  • 62
  • 1
  • 15
1
vote
1 answer

Hive UDF - exetremely slow when parsing IP addresses

I have a column which comprises ip addresses. Now I need to parse them to contries/cities: select IPUtils('199.999.999.999') and it returns ['Aisa', 'Hongkong', 'xxx', 'Hongkong'] I write a hive udf to do this but it runs exetremely slow, as shown…
user2894829
  • 775
  • 1
  • 6
  • 26
1
vote
2 answers

Pandas UDF Function Takes Unusually Long to Complete on Big Data

I'm new to PySpark and Pandas UDFs, I'm running the following Pandas UDF Function to jumble a column containing strings (For Example: an input 'Luke' will result in 'ulek') pandas_udf("string") def jumble_string(column: pd.Series)-> pd.Series: …
The Singularity
  • 2,428
  • 3
  • 19
  • 48
1
vote
1 answer

HugSQL defined function not found

This will probably be very thin but I am running out of options... I am using clojure with hugsql and I am a true beginner with database tech. I am trying to call an user-defined function that a colleague has defined in the database. So, my problem…
1
vote
1 answer

Excel VBA: recalculate in UDF sum by highlight color

I have searched and found several similar questions asked but have been unsuccessful finding a solution. I was hoping I could use an array formula to sum by color, but this is not possible it appears. Instead, I am venturing into this vba solution…
KyotoKitty
  • 11
  • 1
1
vote
2 answers

Substring with union working differently in a User Defined Function

I am trying to split a sentence with unlimited characters into multiples of 7 using a SQL UDF. Which means I am trying to break a sentence into rows with 7 characters in each rows. This is the approach that I felt was the quickest. CREATE OR ALTER…
Surya Garimella
  • 317
  • 4
  • 13
1
vote
1 answer

How can I write a for loop so that it tests all 5 of my test cases?

I am supposed to work out the periodic investment amount given the target wealth. This is my user defined code: def contribution_calculator(target_wealth, rate, duration, periodicity): inv_amt = -npf.pmt(rate/100/periodicity,…