comunica / sparqlee

⚙️ SPARQL expression evaluator library - Moved to @comunica/expression-evaluator
https://www.npmjs.com/package/sparqlee
14 stars 7 forks source link

Async super type discovery and getting full context in regular functions. #113

Closed jitsedesmet closed 1 year ago

jitsedesmet commented 3 years ago

In #112 we closed #109 . We did this in a sync way. It would however be beneficial if the superTypeCallback had type (unknownType: string) => Promise<string> in the AsyncEvaluator. This way a user could for example perform a web call to discover the super type.

We might also want regular functions to get the whole context instead of just the SharedConfig. This way we can make BNODE a regular function. This is also important for the above feature since it is pretty likely we want to do some type checking in regular function in the future.

I made a first implementation of this. I had a few problems.

  1. Making regular functions also have an async implementation makes it that a lot of code gets 'almost' duplicated. It also creates some problems in the aggregators. The Average aggregator for example calls a regular function in its result function. This creates problems for backwards compatibility because we can't make the result function be async.
  2. Having an async superTypeCallback results in a lot of code duplication, mainly in the transformers.

We should find a way to reduce code duplication and we should find a way to keep the result function of aggregators sync.

One way would be copying the function implementation used but I don't really like this idea because it is again, duplication. We could also split regular function in context dependent and non context dependent regular functions. This would be a solution because the functions used don't require the (complete) context. I don't like this either because we already separate in regular and special functions and I feel like this would again complicate things. We could also wait for a major release to provide this feature?

jitsedesmet commented 1 year ago

The supertype discovery would disappear in comunica because of a mismatch with the actors. @rubensworks and I decided that having the Sparqlee function actors is more important than supertype discovery.