qlik-oss / server-side-extension

A Qlik server-side extension protocol for extending the Qlik built-in expression library with functionality from external calculation engines.
MIT License
155 stars 126 forks source link

Functions with a variable number of parameters #34

Open nabeel-oz opened 6 years ago

nabeel-oz commented 6 years ago

Description

Currently the examples don't cater for functions that take in a variable number of parameters. After working on my Python SSE project I find this to be a common requirement:

At the moment I can only see one workaround, which is to concatenate all the required parameters/ measures into a string in Qlik and pass it as a single parameter. The SSE then has to parse the string and extract the parameters/ measures. While I have got this working, a better implementation would make the solution more robust.

Things I'd really like to be considered are:

I'm happy to discuss this further and show example use cases.

Environment

Operating system
[x] Windows
[x] Linux
Qlik Sense
[x] Desktop
[x] Server

Versions

josefinestal commented 6 years ago

Hi @nabeel-qlik ! Thank you for your input and suggestions, we really appreciate it. We are aware of the limitations regarding the topics you mentioned, and they are all included in our backlog. However, we don't know when they will be included in a release. We will let you know as soon as we know.

Another workaround would be to define several SSE functions with the different set of parameters(optional/required), and which are all mapped to a single function on the plugin side.

Kind regards, Josefine

nabeel-oz commented 6 years ago

Hi @josefinestal , thanks for confirming that these enhancements are on the to-do list. I think they would greatly simplify the implementation of SSE functions and also the Qlik expressions needed for the current approach.

I have used the workaround you suggested as well, but that brings up another limitation that the function names exposed to Qlik must be unique. It only makes sense to use this workaround when the functions have distinctly different usage. It would be good if we can define one function name with several signatures and have the help syntax displayed similar to native Qlik expressions:

native qlik expression

qlik-aoh commented 6 years ago

Hi @nabeel-qlik ,

Thanks for the feedback, we appreciate it!

For the use case of specifying a variable number of arguments to a function, I have sometimes used EvaluateScript as a routing mechanism, using the script variable to specify which function to call.

This allow expressions with different number of arguments , like p.ScriptEval('sum', a, b) and p.ScriptEval('sum', a, b, c, d).

This still has many limitations and is of course not as good as proper support for variadic functions, but it is a useful workaround in some situations.

Thanks, Markus

JensB123 commented 2 years ago

Hi @josefinestal & @qlik-aoh,

Is the extension still under active development and if so, is the mentioned issue still in the backlog? Atm I face the same problems as @nabeel-oz.

Thanks in advance!

Jens

countnazgul commented 1 year ago

I know this is an old issue but just stumbled into the same question. And was wondering if there is an update on this topic.

Stefan