RethinkDB “IS NULL” in a where clause filter

I find the syntax for RethinkDB filtering a little unintuitive – if this was actually Javascript, you might expect to see “row[‘Query’]”. I expect this allows them to instrument the queries more easily, although considering they are supposedly translating this into an intermediate language, this doesn’t seem necessary.

To do equality, non-equality, and so on, there are several functions available (ne / eq / gt / lt). I suspect that the reason for this is that the getter function for a column always returns an object – so it can’t be “equal” to null. This is likely a Builder pattern that lets them lazy-execute results; if this database goes the direction of Oracle’s optimizer it will also provide opportunities for query rewriting.

The key is, using Javascript operators will be syntactically correct, but will not work. Unfortunately the RethinkDB editor does not warn you about this, or auto-correct them.

r.db('performance')
.table('query_timings')
.filter(
  function(d){ 
    return d('Query').ne(null) 
  }) 

Hopefully in the future we’ll also see ES6 functions, to make this more compact.