Johannes
Johannes

Reputation: 2121

Array and object lookups in JSONiq

I'm currently working on improving JSON querying capabilities with Brackit[1] and [2], which is an XQuery engine with additional arrays and "records". I'm now basically following the same XDM as JSONiq uses, but I'm sadly no XQuery expert. I guess I've more or less taken over the project from Sebastian and especially added temporal enhancements.

Brackit uses a dereferencing operator => for records / objects to get the value for a name.

Additionally it uses [[expr()]] for array index lookups, I guess just like the pure JSONiq specification.

I'm sure you have good reasons to do the dynamic function calls instead, so I might have to change it. However, I thing that the dereferencing operator might work in all cases, which is in my opinion a nicer syntax.

I think this vision is great to have a query compiler for semi-structured data with proven optimizations for use in data stores: http://wwwlgis.informatik.uni-kl.de/cms/dbis/projects/brackit/mission/

One of the decisive features of Brackit might be the pipelining of FLOWR expressions for set-oriented processing.

kind regards

Johannes

[1] https://github.com/sirixdb/brackit

[2] http://wwwlgis.informatik.uni-kl.de/cms/fileadmin/publications/2013/Dissertation-Baechle.pdf

Upvotes: 0

Views: 176

Answers (1)

Ghislain Fourny
Ghislain Fourny

Reputation: 7279

Thank you for your question, Johannes.

Array and object lookup with dynamic function calls was introduced in very early versions of JSONiq, which started as an extension of XQuery. It is common practice in language design to try to reuse existing machinery in early investigations, before extending the data model and syntax.

Since objects and arrays can be seen as "extensional functions" that explicitly list the input-output pairs, (ab)using dynamic function calls for object and array lookup is quite natural. This approach was also taken in XQuery 3.1.

Syntactic extensions came later. In the "pure JSONiq" syntax, we opted for .Expr for objects and [] as well as [[Expr]] for arrays (double [[]] to not confuse with predicates). XQuery 3.1 also adds a convenient syntax with ? for both objects and arrays.

For FLWOR expressions I recommend looking into Rumble, which pretty much does pipelines in that way already. The paper is here.

Upvotes: 0

Related Questions