The Query System
We compose valid syntax using the following components:
source |> verb(...)
- where "source" must be a valid source
- and "verb" must be a valid verb
Can be either
sourcemust be a valid identifier (subject to possibly more conditions), or
(source |> verb1(...) |> ...)(i.e. a source that has been piped through a sequence of
- ... (e.g.
:tableas a placeholder for a table)
- prefer lowercase names (i.e. lowercasename instead of LowerCaseName, etc) - allow underscores (e.g. lower_case_name and lowercasename are both valid) - can be prefixed by a table name (e.g. `table.columnname` and `columnname` are both valid) - should maybe follow a reference, e.g. https://msdn.microsoft.com/en-us/library/ms175874.aspx#Anchor_1
- should support (API functions that registered verbs will need to implement) - convention: lowercase english verbs, allow underscore, etc - each verb should be called like the following: `verb(arg1, arg2, ..., keyword1(kw1arg1, kw1arg2, ...), keyword2(kw2arg1, kw2arg2, ...))` where - keywords should satisfy the following rules to be a valid name (..., might follow mostly the same rules as verbs) - arguments e.g. `arg1, arg2, kw1arg1, ..., kw2arg2, ...` will have to satisfy the conditions for being a valid expression
can be either a - valid identifier (see point 2) - valid function call (see point 6) - valid ...
- conventions: functions should satisfy the following rules to be a valid name (..., e.g. lowercase english verbs, allow underscore, etc) - should satisfy ... rules
type CustomNode <: AbstractQuery.AbstractQueryNode source args [possibly: parameters, helpers, ...] end
- source is ...
- args is ...
- etc is ... (environment, helpers, etc)
to register it:
AbstractQuery.QUERYNODE[:customverb] = CustomNode
(not the responsibility of the specification to dictate)
- User-Defined Function (UDF): maps a tuple to a “scalar”.
- User-Defined Aggregation Function (UDAF): translates a whole table into a single “scalar”.
- User-Defined Table Function (UDTF): expands a tuple into a table.
How should users register their functions?
- [ ] verbs? - [ ] functions? - [ ] keywords? - [x] expressions
- [ ]
Resolution for extensions with clashing names (if any)?
bleargh (first-come-first-serve? module.verb?)
Up to the individual backends how they should interpret the query expressions/object