Skip to main content

Hi there,

I was wondering if we can create our own functions in queries.

For this I am using the example provided in the VERTICA documentation.

https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/ExtendingVertica/UDF-SQLFunctions/CreatingUser-DefinedSQLFunctions.htm

Query 1: Create function

CREATE FUNCTION myzeroifnull(x INT) RETURN INT

AS BEGIN

RETURN (CASE WHEN (x IS NOT NULL) THEN x ELSE 0 END);

END;

Query 2: Create tabel

CREATE TABLE tabwnulls(col1 INT);

INSERT INTO tabwnulls VALUES(1);

INSERT INTO tabwnulls VALUES(NULL);

INSERT INTO tabwnulls VALUES(0);

SELECT * FROM tabwnulls;

 

Query 3: Check if function exists

​I can see that the function is listed under USER_FUNCTIONS

(see https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/ExtendingVertica/UDF-SQLFunctions/ViewingInformationAboutUser-DefinedSQLFunctions.htm)

 

SELECT * FROM USER_FUNCTIONS WHERE function_name = 'myzeroifnull'

Query 4: use function

SELECT myzeroifnull(col1) FROM tabwnulls;

>> Ausführungsfehler: Function MYZEROIFNULL is not supported

 

 

Am I doing something wrong here or is this functionality not supported by Celonis?

 

All the best,

Saša

 

 

Hi @sasa.redze12, thanks for posting questions that make us think!

My first impression is that the created function will only be saved in memory during the sql execution, if you put togegther at query 4:

CREATE OR REPLACE FUNCTION myzeroifnull(x INT) RETURN INT

   AS BEGIN 

     RETURN (CASE WHEN (x IS NULL) THEN 0 ELSE x END); 

   END;

SELECT myzeroifnull(col1) FROM tabwnulls;

 

Then works perfectly, if you follow the steps one after the other I receive the same error: Execution error: Function MYZEROIFNULL is not supported

 

Then the next question could be, is there a way that the user functions remain persistent?

 


Hi @sasa.redze12, thanks for posting questions that make us think!

My first impression is that the created function will only be saved in memory during the sql execution, if you put togegther at query 4:

CREATE OR REPLACE FUNCTION myzeroifnull(x INT) RETURN INT

   AS BEGIN 

     RETURN (CASE WHEN (x IS NULL) THEN 0 ELSE x END); 

   END;

SELECT myzeroifnull(col1) FROM tabwnulls;

 

Then works perfectly, if you follow the steps one after the other I receive the same error: Execution error: Function MYZEROIFNULL is not supported

 

Then the next question could be, is there a way that the user functions remain persistent?

 

Puzzling indeed 😄


I have the same behavior. What a pity, that's useless.


Reply