Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
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.

null

Boolean

true or false

truefalse

Integer

Whole numbers (no fractional component)

1-2

Decimal

Decimal numbers (optional fractional components)

1.0-2.19743

String

Text

'221B Baker Street'

DateTime

Date and time, in ISO8601 format

to_timestamp('2004-10-19T10:23:54Z')

Object ID

Unique object identifier.

OID('507f1f77bcf86cd799439011')

Clauses

The following clauses are supported:

Type

Clauses

Basic

SELECTASFROM

Joins

LEFT JOININNER JOINJOIN

Filtering

WHERE

Grouping

GROUP BYHAVING

Subquery

FROM (SELECT ...) AS

Paging

LIMITOFFSET

Sorting

ORDER BY , DESCASC

Conditional

CASE WHEN ELSE

The following operators are supported:

Type

Operators

String

LIKENOT LIKE

Relational

=>=<=<>INNOT IN

Boolean

ANDORNOT

Null

IS NULLIS NOT NULL

Projection

foo.bar

Mathematical

+, -, *, /, %

The following functions are supported by default (this can be extended with new functions). Those are case insensitive:

Type

Functions

String

CONCATLOWERUPPERSUBSTRINGLENGTH

DateTime

DATE_PARTTO_TIMESTAMP

Arrays

UNZIP (only in project)ELEMAT

Geo

GEOWITHIN (only in where)

Set-Level

DISTINCT

Aggregation

COUNTSUMMINMAXAVG, FIRST, LAST

Conversion

TOINT, TOBOOL, TOSTRING, TOOBJECTID (or OID), TODOUBLE,TOLONG, TODATE, TODECIMAL

Timeserie

UNZIPTS (only in project)

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

select concat('Cuisine ', c.Restaurant.cuisine) from Restaurants as c

Return combination of all strings

String

LOWER, UPPER

1 String or column with type string

all

select concat('Cuisine ', upper(c.Restaurant.cuisine)) from Restaurants as c

lowercase/uppercase of string

String

SUBSTRING

3 String or column with type string, index (integer), length (integer)

all

select concat('Cuisine ', substring(c.Restaurant.cuisine,2,3)) from Restaurants as c

substring of string

String

LENGTH

1 String or column with type string

all

select length(c.Restaurant.cuisine) from Restaurants as c

length of string

String

TRIM

1 String or column with type string

all

SELECT trim(' aaa '), trim(c.Restaurant.borough) FROM Restaurants AS c LIMIT 300

trim a string

DateTime

DATE_PART

2 part type ("month","year","dayOfMonth","hour","minute","second",
"millisecond","dayOfYear","dayOfWeek","week"), timestamp or field with timestamp type

all

SELECT date_part('year',timestamp) as year, date_part('month',timestamp) as month FROM QA_DETAIL AS c LIMIT 3

SELECT date_part('dayOfMonth',timestamp) as day, count(*) FROM QA_DETAIL AS c group by day

get date part from timestamp

DateTime

TO_TIMESTAMP/TIMESTAMP

1 timestamp or field with timestamp type

all

SELECT timestamp FROM QA_DETAIL AS c where timestamp > to_timestamp('2018-10-24T23:00:00.000Z') LIMIT 3

SELECT timestamp FROM QA_DETAIL AS c where timestamp > timestamp('2018-10-24T23:00:00.000Z') LIMIT 3

convert string to timestamp

Arrays

UNZIP

2 array type field, boolean (preserve null and empty arrays in unzip)

project

select unzip(Restaurant.grades,true) from Restaurants

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

select elemat(Restaurant.grades,1) from Restaurants

get element by position in array

Geo

GEOWITHIN

2 geometry point field, geometry

where

select * from Supermarkets where geoWithin(Supermarkets.geometry, '{type : "Polygon" , coordinates: [ [ [-15.44488, 28.137924], [-15.423848, 28.137924], [-15.423848, 28.144054], [-15.44488, 28.144054], [-15.44488, 28.137924] ] ] }')

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

select count(*) from Supermarkets

count

Aggregation

SUM, MIN, MAX, AVG, FIRST, LAST

1 field (type depending on operation)

project or having

select min(c.Supermarkets.status) as maxs from Supermarkets as c

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

select concat('Cuisine ', UPPER(c.Restaurant.cuisine), ' of length ',toString(length(UPPER(c.Restaurant.cuisine)))) as complex from Restaurants as c

conversion between type

Timeserie

UNZIPTS

2 window type in String (uppercase), window frequency in String (uppercase)

project

SELECT unzipts('DAYS','MINUTES') FROM timeserie AS c LIMIT 3

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