[xquery-talk] [xml-dev] Mistakes made in the design of XQuery 3.1

daniela florescu dflorescu at me.com
Sat May 30 12:43:57 PDT 2015

> ***************
> Things that are absolutely necessary for semi-structured query languages
> **************
> 1.Conditionals, typeswitches
> In schema-less data, we never know what we’ll find. We HAVE to be able to branch based on what we find in the data while searching.
> 2. Functions and recursive functions
> While dealing with nested, pre-aggregated data, we need to navigate structures on unknown depth, and for this we really need functions
> and recursive functions.
> 3. Error management: try/catch

In this list I forgot something really important for any kind of query language for semi-strcutured data;

4. A battery of implicit type conversions.

Data being of unexpected shape and type, we can never be sure that the data operations get at runtime is what you expected when you wrote the query.

Defining those is an **ART** (with capitals:-), because one need to make a compromise between:
- not being too strict, otherwise everything ends up in an error
- not being too lax ("anything goes" kind of thing), because you introduce errors in the resulting data
- making sure that the implicit type conversion are done such that you can STILL use indexes (if you index a value as an integer and at runtime it gets converted and 
used as string in an equality… are you still able to use the index !?)
-usability and symmetry ; such implicit conversions happen in a variety of places (function calls, equality, arithmetics, groupby, sort, etc, etc) and you have to make sure that
they are kind of symmetrical and obey the “principle of least surprise”  and also allow optimizability, aka expression rewriting

At least 25% of the design of XQuery has spent in the design of this battery of implicit type conversions.

I think the result is decent. I am not ware of any major mistake, that I wish we would have done better, or differently. But everything was design by trail, design, implementation, usage, error, 
designe, implementation, etc, etc. That’s why it took an eternity to design them, and for XQuery to get standardized.

I honestly don’t wish even my worst enemy to start this process from scratch, and I wish the NoSQL community would have learned from what we’ve done.

Wishful thinking on Saturday morning, best regards

More information about the talk mailing list