SparkQL BNF Grammar
This document explains the rules for the Spark API filter language syntax and is a living document generated from the reference implementation at https://github.com/sparkapi/sparkql.
Unless otherwise specified, SparkQL follows SQL precendence conventions for operators and conjunctions. Unary minus is always tied to value, such as for negative numbers.
A filter (target) is a composition of filter basic filter expressions.
| /* none */
One or more expressions
The core of the filtering system, the expression requires a field, a condition and criteria for comparing the value of the field to the value(s) of the condition. The result of evaluating the expression on a resource is a true of false for matching the criteria.
: field OPERATOR condition
| field RANGE_OPERATOR range
Some conjunctions don't need to expression at all times (e.g. 'NOT').
: UNARY_CONJUNCTION expression
Two expressions joined together using a supported conjunction
: expressions CONJUNCTION expression
| expressions UNARY_CONJUNCTION expression
One or more expressions encased in parenthesis. There are limitations on nesting depth at the time of this writing.
: LPAREN expressions RPAREN
Keyword for searching on, these fields should be discovered using the metadata rules. In general, Keywords that cannot be found will be dropped from the filter.
The determinant of the filter, this is typically a value or set of values of a type that the field supports (review the field meta data for support). Functions are also supported on some field types, and provide more flexibility on filtering values
Functions may replace static values for conditions with supported field types. Functions may have parameters that match types supported by fields.
: function_name LPAREN RPAREN
| function_name LPAREN function_args RPAREN
Functions may optionally have a comma delimited list of parameters.
| function_args COMMA function_arg
A comma delimited list of functions and values.
| literal_list COMMA literals
| literal_list COMMA function
A comma delimited list of values that support ranges for the Between operator (see rangeable).
: rangeable COMMA rangeable
Literals that support multiple values in a list for a condition
Literals only support a single value in a condition
Functions, and literals that can be used in a range