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

Calculate average invested price without helper columns/tables

This post is really worth a read. Another better verion of this topic is available here. If you look at the table below, I am trying to find Avg price at every transaction without adding helper columns. The Average price is correct when the side is…
1
vote
2 answers

Using pandas functions with Pyspark

I'm trying to rewrite my Python script (Pandas) with Pyspark, but I can't find a way to apply my Pandas functions in a way to be more efficient with Pyspark functions: my functions are the following: def decompose_id(id_flight): …
f.ivy
  • 65
  • 5
1
vote
1 answer

Snowpark calling pre-compiled Java UDFs

I am working on a very simple Snowflake example to call a pre-compiled Java UDF from Intellij. I have made a jar out of my Java UDF and want to call this from Intellij where i am trying to execute the UDF on snowflake. I want to know how I can…
SGN
  • 341
  • 1
  • 7
  • 23
1
vote
1 answer

Is there any function to split CIDR block into IP start and IP end without using Parse_IP in snowflake

for example For cidr 2c0f:eb00:400::/40 (jw.org) ip_start should be - 2c0f:eb00:400:: ip_end will be - 2c0f:eb00:4ff:ffff:ffff:ffff:ffff:ffff
1
vote
2 answers

How to apply def function in full dataframe?

I need help to correct the function. I am confused for two things. how to put for loop into def function. Please, Correct my other function. It works only on single column raw_data = {'age1': [23,45,21],'age2': [10,20,50]} df =…
1
vote
2 answers

How to get the partitionId or taskContext of Spark in hive UDF when SQL executed with Spark engine?

For example, we execute the SQL below with Spark engine, we need my_udf(row) return the partition id in Spark. add jar hdfs:///dir/udf/udf.jar; create temporary function my_udf as 'com.my.MyUDF'; select row, my_udf(row) from table; I have known…
Shawn.X
  • 1,323
  • 6
  • 15
1
vote
1 answer

Passing Arrays of Structures to User-defined Functions in C

I was confused on the concept of passing a structure of arrays in C programming. Most examples involve passing an array of structures with the values already provided. I had to ponder, reread, and it clicked when I saw someone take input and put the…
JLpng
  • 11
  • 1
  • 4
1
vote
1 answer

How to parse HTML with a Snowflake UDF

Snowflake supports JavaScript UDFs, but the DOM Parser doesn't work (for security reasons). For example, I get these errors with a JS UDF: JavaScript execution error: Uncaught ReferenceError: document is not defined JavaScript execution error:…
1
vote
1 answer

What JDK version does Snowflake support for Java UDFs?

Snowflake now supports Java UDFs: https://medium.com/snowflake/new-in-snowflake-java-udfs-with-a-kotlin-nlp-example-e52d94d33468 How can I tell what version of the JDK is Snowflake using?
Felipe Hoffa
  • 54,922
  • 16
  • 151
  • 325
1
vote
1 answer

Split PySpark Map-like string into Map Object

I have a column in PySpark containing dictionary/map-like values that are stored as strings. Example Values: '{1:'Hello', 2:'Hi', 3:'Hola'}' '{1:'Dogs', 2:'Dogs, Cats, and Fish', 3:'Fish & Turtles'}' '{1:'Pizza'}' I'd like to convert these strings…
1
vote
1 answer

Hive UDF to mask/transform certain attributes of an array<> data type in Hive

I need to mask certain attributes of a column with array((struct)) data type in Hive. For example, a field, biodata = [{'name':'Rahul','age':20,'gender':'male'},{'name':'Kavita','age':25,'gender':'female'}] Here, I need to mask/encrypt 'name'…
1
vote
1 answer

why do i run into a runtime error (range) when im trying to execute a timestamp user defined function

I have a sheet which i want people to populate manually One of these columns is for a date and a timestamp, rather then manual entry for this as its pretty awkward for noobs on excel i have made a user defined function and assigned to a button...…
1
vote
1 answer

Allow users to create new categories and fields on ASP.NET website

We have a db driven asp.net /sql server website and would like to investigate how we can allow users to create a new database category and fields - is this crazy?. Is there any examples of such organic websites out there - the fact that I havent…
John
  • 11
  • 1
1
vote
1 answer

Is it possible to allow a user to call a BigQuery UDF but not see its definition?

I have a BigQuery User Defined Function (UDF) in which the definition contains a secret: CREATE FUNCTION mydataset.HashWithPepper(input STRING, y INT64) RETURNS STRING AS SHA256(input +…
jamiet
  • 10,501
  • 14
  • 80
  • 159
1
vote
2 answers

Checking if field contains multiple string in sql server

I am working on a sql database which will provide with data some grid. The grid will enable filtering, sorting and paging but also there is a strict requirement that users can enter free text to a text input above the grid for example 'Engine 1001…
vanpersil
  • 764
  • 1
  • 8
  • 26
1 2 3
99
100