Whitespaces in UDF script parametrization

schiegg
Contributor

I am trying to extend one of my UDF scripts to a broader use case.
Currently I am stuck at this error message:

[...] invalid type: status" in input-parameter list found at [...]

when I enter:

CREATE OR REPLACE JAVA SET SCRIPT EXAMPLE_SCRIPT (id INT, example VARCHAR(255), "example status" VARCHAR(255)) EMITS ...

 

I already tried `example status` and 'example status' but only replacing the whitespace by e.g. "example-status" makes it work. This manual replacement would mean a lot of work in my code which builds this expressions by input files.

Can someone tell me if I am doing something wrong or this is a system limitation?
Thanks in advance!

5 REPLIES 5

mwellbro
Xpert

Hi @schiegg ,

not my forte, but I think exasol does not accept blanks in script parameter names, see https://docs.exasol.com/sql/create_script.htm#microcontent1 :

mwellbro_0-1626953983134.png


No indication that quotes are eligible for use here and the underscore between param and name seems to indicate what you are experiencing is "by design".

But we should wait for a verdict by exasol - their code-gen still generates this, even though the Java code that ensues is questionable regarding the variable name:

mwellbro_1-1626954089637.png


Cheers,
Malte

mwellbro
Xpert

just to add on that: double quotes can be used ( perhaps with regards to upper/lower case ), but blanks are still a no-go, seems like:

CREATE OR REPLACE JAVA SET SCRIPT EXAMPLE_SCRIPT("id" VARCHAR(2000000)) 
EMITS(test INT) AS 
class EXAMPLE_SCRIPT {
 static void run(ExaMetadata exa, ExaIterator ctx) throws Exception {
 // TODO: implement script
 do {       // loop over input
  String id = ctx.getString("id");     // access input variable
 } while(ctx.next());
 ctx.emit(10);
 }
}
/

mwellbro_0-1626956377000.png

 

drumcircle
Rising Star

Pro-tip: to use global replacements, right click on your schema in DBViz pro and then export schema.  You can export all scripts as text file, do bulk edits, and re-import them.

exa-MathiasHo
Community Manager
Community Manager

Hi @schiegg

Please let us know if the answers helped you out and mark one as a solution. This way, other users, who might have the same question, can learn from it too.

exa-Aleksandr
Team Exasol
Team Exasol

Hi @schiegg 

The part of parsing pipeline that handles parameter list is common between Java and other UDF languages (python, R).

And for python / R we try to obey with their identifier name rules to be able to access parameter values via ctx.parameter_name / ctx$parameter_name.