Hi Grainier, in my opinion, this would definitely be a very interesting addition! We already briefly discussed such a feature in the past, before we went to the ASF. I’d say that a JS evaluator would be definitely useful to a slightly more technical target user group, but would provide great flexibility for, e.g., data harmonization tasks. So let’s discuss what is needed to implement this! I’d guess that we (maybe) need to add some enhancements to the core to make this processor good from a usability perspective.
>From a conceptual point of view, I guess the JS processor would have no >specific input requirements and a single static property that allows users to >enter the code (maybe it would be cool to add a new static property here that >supports code highlighting or even syntax checking). The only open issue I see >is the output schema – we would somehow need to extract the output from the JS >function. This could probably partially be done using the >CustomTransformOutput (see >http://streampipes.apache.org/docs/docs/dev-guide-output-strategies/), but we >would somehow need to derive type information from the JS function or >introduce a feature to let users define/refine the output manually (e.g., to >add semantic metadata). What do you think would be best? And would you evaluate the JS code in Java or somehow else? Also, as I’ve just started to improve the SDK (e.g., supporting optional static properties and an easier way to define and extract model parameters), we can collect your requirements for the JS processor and extend the SDK if needed, just say what you would like to have 😉 Dominik From: Grainier Perera <[email protected]> Sent: Wednesday, May 13, 2020 2:41 PM To: [email protected] Subject: Data processor to evaluate JavaScript Hi all, I'm planning to implement a JavaScript eval data processor. As the name suggests, users will be able to write some JavaScript code which takes in an event (as a map), do some processing on the event, and return a new map which then gets converted to an sp-event. example js: function process(event) { // do processing here. // return processed event. return {id: http://event.id, tempInCelsius: (event.tempInKelvin - 273.15)}; }; Will this be a good addition to pipeline-elements? What do you think? Regards, Grainier.
