MilliEQL is a small query language built for embedding within applications. It supports logic for querying and manipulating data in a simple, typesafe manner.
Having a simple query language allows
- Shared frontend / backend logic for form validation or price calculation.
- User-submitted logic
- Cross-language serializable functions
In the past, I've used JSON Logic for such tasks, but JSON logic leaves a bit to be desired:
- It's not very expressive, and even simple things can prove quite annoying to implement
- It doesn't have a dedicated syntax, making reading and writing extremely challenging
// JavaScript
import millieql from 'millieql';
millieql.query(query, { events: [...] })
# Python
import millieql
millieql.query(query, {"events": [...]})
The following are simple examples of how MilliEQL could be used.
events | filter type="submit" | count
events | groupby type | mapvalues count
lines | sort -overallScore | first
events | filter type="send_message" | groupby email | keys
events | sort timestamp | groupby email | mapvalues (sequence type == "purchase", type == "signup") | filtervalues count > 0 | keys
MilliEQL's types correspond closely to JSON types, for interoperability between different languages.
MilliEQL has 4 primitive types:
string
number
null
boolean
MilliEQL also has 3 complex types:
Struct
Array
Function<T, K>
The interface of MilliEQL is restricted in that functions can neither be provided as data, nor returned as the result of a query -- they exist entirely within MilliEQL
The following is a reference of the builtin functions of MilliEQL
keys
values
map
filter
mapvalues
filtervalues
mapkeys
filterkeys
groupby
find
index
first
last
summarize
count