Supported SQL Keywords
|
The |
|
the |
|
Orders the values returned by a SELECT statement ascending ( |
|
|
|
Eliminates duplicate rows. |
|
Groups together rows in a table that have the same values in all the columns listed. |
|
Specifies the number of records to return. |
|
Places an upper bound on the number of rows returned by the entire |
|
|
RBQL variables
Value of i-th field in the current record in input table a1, a2,…, a{N} |
|
Value of i-th field in the current record in join table B b1, b2,…, b{N} |
|
Record number (1-based) NR |
|
Number of fields in the current record NF |
|
Value of the field referenced by it’s “name”, You can use this notation if the field in the header has a “good” alphanumeric name. a.name, b.Person_age, … a.{Good_alphanumeric_column_name} |
|
Value of the field referenced by it’s “name”, You can use this notation to reference fields by arbitrary values in the header. a[“object id”], a[‘9.12341234’], b[“%$ !! 10 20”] … a[“Arbitrary column name!”] |
Aggregate functions
|
Returns a count of the number of times that X is not NULL in a group. |
|
Collects all the input values, including nulls, into an array. |
|
Returns the minimum non-NULL value of all values in the group. |
|
Returns the maximum value of all values in the group. |
|
Return sum of all non-NULL values in the group. |
|
Returns the average value of all non-NULL X within a group. |
|
Returns the population standard variance. |
|
Return the median (middle value) of numeric data. |
Aggregate statements
|
[ LEFT JOIN and INNER JOIN Join table B can be referenced either by its file path or by its command - an arbitrary string name the user should provide before executing the JOIN query. |
|
Can be used to select everything except specific columns. E.g. to select everything but columns 2 and 4, run:
|
|
You can set whether the input (and join) CSV file has a header or not using the environment configuration parameters which could be --with_headers CLI flag or GUI checkbox or something else.
But it is also possible to override this selection directly in the query by adding either WITH (header) or WITH (noheader) statement at the end of the query.
Example: |
|
|
|
RBQL does not support LIKE operator, instead it provides “like()” function which can be used like this: |
User Defined Functions
User Defined Functions (UDF) RBQL supports User Defined Functions
You can define custom functions and/or import libraries in two special files: |
Examples
With Python expressions
|
|
With JavaScript expressions
|
Notes
- Keywords are case insensitive
Limitations:
- Aggregate functions inside Python (or JS) expressions are not supported. Although you can use expressions inside aggregate functions.
MAX(float(a1) / 1000)
- valid;
MAX(a1) / 1000
- invalid. - RBQL doesn’t support nested queries, but they can be emulated with consecutive queries.
- Number of tables in all
JOIN
queries is always 2 (input table and join table), use consecutive queries to join 3 or more tables.
- Aggregate functions inside Python (or JS) expressions are not supported. Although you can use expressions inside aggregate functions.
RBQL is integrated with Rainbow CSV extensions in Vim, VSCode, Sublime Text and Atom editors.
RBQL in npm:
$ npm install -g rbql
RBQL in PyPI:
$ pip install rbql