Info |
---|
Disponible en versión 2.2.0-hyperblast |
...
Los datos tipo string son con ' siempre
Los joins, se limitan al uso sólo de inner join y left join. No es válida la sintaxis de múltiples orígenes comas select * from ontology1, ontology2,….
El timestamp desde string cambia de timestamp '' a la función to_timestamp('')
El $oid desde string cambia de OID '' a la función OID('') o toObjectId('')
Las proyecciones de array u objetos tipo .* .0 [2] [*] {*} no están soportadas, es posible su implementación con funciones
No se puede concatenar con ||, hay que usar la función concat()
No se puede usar el alias o el nombre de la ontologías para hacer las proyecciones ni con *. Serían incorrectas estas queries (en su lugar hay que usar 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
Consideraciones del ObjectID y el _id
...
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 |
|
Ejemplos de uso
Queries Básicas:
...
Se dispone de varias funciones incluidas en el motor por defecto (estas son ampliables mediante configuración). Se usan en modo case insensitive por lo que pueden escribirse indistintamente en mayúsculas o minúsculas:
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 |
Trabajo futuro
...
Posibilidad de uso de unions (sólo mongo 4.4 en adelante)
...
Uso de subqueries en where
...
Count Distinct clause (Desde 4.2.1-predator)
Con esta clausula puedes realizar la operación de conteo de distintos valores de un grupo (el incluido en el distinct) para otro grupo dado (el que está fuera del distinct)
select count(distinct Restaurant.borough) from Restaurants
...
select Restaurant.cuisine, count(distinct Restaurant.borough, Restaurant.name) from Restaurants
...
Por restricciones del lenguaje de consultas de mongodb, no esta permitido la combinación con otros elementos diferentes de columnas.