Exasol - Advance Analytics course error

Contributor

Hi ,

Created a simple script 

--/

CREATE OR REPLACE PYTHON SCALAR SCRIPT fruits_list(fruit varchar(20000) , price decimal(18,2))

     RETURNS VARCHAR(200000) AS

def run(ctx)

 return ctx.fruit

/

Its giving error 

 

 

 

SQL Error [22002]: VM error: SyntaxError: invalid syntax (FRUITS_LIST, line 1) (Session: 1672016243267889055)

 

 

 



1 ACCEPTED SOLUTION

Contributor

It's because of the indentation.
We need to be very careful while using Python / other scripts.

View solution in original post

4 REPLIES 4

Contributor

correct Syntax ":" is missing in previous one : 

  --/

CREATE OR REPLACE PYTHON SCALAR SCRIPT fruits_list(fruit varchar(20000) , price decimal(18,2))

       RETURNS VARCHAR(200000) AS

def run(ctx):

 return ctx.fruit

/

 

Contributor

calling script as 

select fruits_list('test',1.2) ;

Contributor

It's because of the indentation.
We need to be very careful while using Python / other scripts.

View solution in original post

Moderator
Moderator

Good to see you were able to sort this out - and thank you for this contribution!

Even though the issue you mentioned is something Python-specific (and we don't aim to teach Python in the first place), we actually pointed out this sensitivity in the very first video clip that talks about UDF scripts (UDF scripts in Exasol), saying:

"As it is Python, it is very important to indent the lines of code within the function."