Info |
---|
Available in version 2.2.0-hyperblast |
...
String data are with ' always
Joins are limited to the use of inner join and left join only. The syntax of multiple comma origins is not valid: select * from ontology1, ontology2,….
The timestamp from string changes from timestamp '' to to_timestamp('') function.
The $oid from string changes from OID '' to OID('') or toObjectId('') function.
Array projections or .* .0 [2] [] {} type objects are not supported, implementation with functions is possible.
You cannot concatenate with ||, you must use the concat() function.
You cannot use the alias or the name of the ontology to make the projections nor with *. These queries would be incorrect (instead you should use select * from Ontology):
SELECT c FROM Ontology AS c LIMIT 3
SELECT c.* FROM Ontology AS c LIMIT 3
SELECT Ontology FROM Ontology AS c LIMIT 3
SELECT Ontology.* FROM Ontology AS c LIMIT 3
ObjectID and _id considerations
...
Extensibilidad del nuevo motor SQL de mongo
Sintaxis
Data Types
Type | Description | Examples |
---|---|---|
Null | Indicates missing information. |
|
Boolean | true or false |
|
Integer | Whole numbers (no fractional component) |
|
Decimal | Decimal numbers (optional fractional components) |
|
String | Text |
|
DateTime | Date and time, in ISO8601 format |
|
Object ID | Unique object identifier. |
|
Clauses
The following clauses are supported:
Type | Clauses |
---|---|
Basic |
|
Joins |
|
Filtering |
|
Grouping |
|
Subquery |
|
Paging |
|
Sorting |
|
Conditional |
|
The following operators are supported:
Type | Operators |
---|---|
String |
|
Relational |
|
Boolean |
|
Null |
|
Projection |
|
Mathematical |
|
The following functions are supported by default (this can be extended with new functions). Those are case insensitive:
Type | Functions |
---|---|
String |
|
DateTime |
|
Arrays |
|
Geo |
|
Set-Level |
|
Aggregation |
|
Conversion |
|
Timeserie |
|
Use Examples
Basic Queries:
...
Several functions are included in the engine by default (these can be extended by configuration). They are used in case insensitive mode so they can be typed case insensitive:
Type | Name | Params | Places | Example | Comments |
---|---|---|---|---|---|
String | CONCAT | 1..* String or column with type string | all |
| Return combination of all strings |
String | LOWER, UPPER | 1 String or column with type string | all |
| lowercase/uppercase of string |
String | SUBSTRING | 3 String or column with type string, index (integer), length (integer) | all |
| substring of string |
String | LENGTH | 1 String or column with type string | all |
| length of string |
String | TRIM | 1 String or column with type string | all |
| trim a string |
DateTime | DATE_PART | 2 part type ("month","year","dayOfMonth","hour","minute","second", | all |
| get date part from timestamp |
DateTime | TO_TIMESTAMP/TIMESTAMP | 1 timestamp or field with timestamp type | all |
| convert string to timestamp |
Arrays | UNZIP | 2 array type field, boolean (preserve null and empty arrays in unzip) | project |
| unzip array in multiple instances. Second param enable/disable preserve null and empty arrays. This function can only be used alone in project because of the changing of the number of records. All filters applied are before unzip. You can use this in a subquery for continue operating over array |
Arrays | ELEMAT | 1 array type field | all |
| get element by position in array |
Geo | GEOWITHIN | 2 geometry point field, geometry | where |
| find some geometry field point in geometry structure as the second arguments. Only in where because mongoDB limitation |
Aggregation | COUNT | 1 field or * | project or having |
| count |
Aggregation | SUM, MIN, MAX, AVG, FIRST, LAST | 1 field (type depending on operation) | project or having |
| aggregation functions. Last and first get first or last of a group |
Conversion | TOINT, TOBOOL, TOSTRING, TOOBJECTID (or OID), TODOUBLE,TOLONG, TODATE, TODECIMAL | 1 field (type depending on operation) | all |
| conversion between type |
Timeserie | UNZIPTS | 2 window type in String (uppercase), window frequency in String (uppercase) | project |
| unzip timeserie into plain strcture returning the instances like when they're inserted. This function can only be used alone in project because of the changing of the number of records. All filters applied are before unzipts. You can use this in a subquery for continue operating over timeserie |
Count Distinct clause (From 4.2.1-predator)
With this clause, you can perform a count operation of distinct values of a group (the group inside distinct clause) for another group (the fields outside of the distinct clause)
select count(distinct Restaurant.borough) from Restaurants
...
select Restaurant.cuisine, count(distinct Restaurant.borough, Restaurant.name) from Restaurants
...
Due to restrictions of mongodb query languaje, it’s not allowed the combination with other elements different than columns