I made this section
|
167 KB
|
17 KB
|
149 KB
We shouldn't use the MongoDB documentation (docs.mongodb.org) as our reference. We may not have full support of every function in the MongoDB syntax. We support only what makes sense in SQL syntax. We should refer to our "MongoSQL Query Reference" document to work on our documentation.
As documented in the MongoSQL Query Reference:
expr | expr
expr & expr
expr << expr
expr >> expr
expr + expr
expr – expr
expr * expr
expr / expr
expr % expr
When I attempt
When I attempt
You are adding two SELECT statements, which is not valid SQL.
You are trying to add two numbers in two different records. The correct SQL is:
SELECT sum(pop) FROM zips WHERE city IN ('BROOKLYN', 'NEW YORK')
You use the + operator to add two numbers in a record, e.g. SELECT col1 + col2 FROM table
You are adding two SELECT statements, which is not valid SQL.
You are trying to add two numbers in two different records. The correct SQL is:
SELECT sum(pop) FROM zips WHERE city IN ('BROOKLYN', 'NEW YORK')
You use the + operator to add two numbers in a record, e.g. SELECT col1 + col2 FROM table
I've got two records that are both integer ( itemID, prodID) and attempt to add them using the + as our MongoDB reference indicates
select itemID + prodID from NewItems where dodad='things'
and I still get
I've got two records that are both integer ( itemID, prodID) and attempt to add them using the + as our MongoDB reference indicates
select itemID + prodID from NewItems where dodad='things'
and I still get
Emil, the math operators are not implemented.
Emil, the math operators are not implemented.
select sum(itemID,prodID) from NewItems where dodad='things'to get the desired result
prodID
argument is ignored and the summarization is done just on the itemID
field.Emil, the math operators are not implemented.
SET number = number + 10
which is implemented using the $inc operator; WHERE qty % 2 = 0
etc).select itemID + prodID from NewItems
and thus the math operation should be applied at the java level by iterating over each document, which wouldn't provide great performance.db.NewItems.aggregate({$project: { "sum" : { $add: ["$itemID", "$prodID" ] } } })
select stats.wins + stats.rbis from baseball
will translate on the next drop todb.baseball.aggregate({$project: { "sum": { $add: ["$stats.wins", "$stats.rbis"] } } })
select sum(itemID,prodID) from NewItems where dodad='things'to get the desired result
prodID
argument is ignored and the summarization is done just on the itemID
field.Emil, the math operators are not implemented.
SET number = number + 10
which is implemented using the $inc operator; WHERE qty % 2 = 0
etc).select itemID + prodID from NewItems
and thus the math operation should be applied at the java level by iterating over each document, which wouldn't provide great performance.db.NewItems.aggregate({$project: { "sum" : { $add: ["$itemID", "$prodID" ] } } })
select stats.wins + stats.rbis from baseball
will translate on the next drop todb.baseball.aggregate({$project: { "sum": { $add: ["$stats.wins", "$stats.rbis"] } } })
Jonathan, the MongoDB JDBC embedded inside ADS doesn't support any of these functions you've mentioned on the wiki page:
ADD, DIVIDE, MOD, MULTIPLY, SUBTRACT, CONCAT
For the first five functions I'll implement for the next mongo-jdbc drop the +, /, %, *, -
operators that will map on the $add , $divide
etc aggregation operators. CONCAT is a string aggregation operator and probably we will support it only if necessary. Please update the wiki page.
Jonathan, the MongoDB JDBC embedded inside ADS doesn't support any of these functions you've mentioned on the wiki page:
ADD, DIVIDE, MOD, MULTIPLY, SUBTRACT, CONCAT
For the first five functions I'll implement for the next mongo-jdbc drop the +, /, %, *, -
operators that will map on the $add , $divide
etc aggregation operators. CONCAT is a string aggregation operator and probably we will support it only if necessary. Please update the wiki page.
Thank you for the corrections.
I've taken out all the inappropriate contents of the math section.
Thank you for the corrections.
I've taken out all the inappropriate contents of the math section.
For the nosql-jdbc drop, math expressions ( + , - , *, / , % ) will be supported on WHAT fields ( e.g. select itemID + prodID from NewItems
) and inside WHERE filters (e.g. select * from NewItems where itemID + prodID < 1000
).
For the nosql-jdbc drop, math expressions ( + , - , *, / , % ) will be supported on WHAT fields ( e.g. select itemID + prodID from NewItems
) and inside WHERE filters (e.g. select * from NewItems where itemID + prodID < 1000
).
I am using nosql-jdbc 1.0.4. The _id field is always returned with the result set when a math expression is used in the SELECT field list. See attached screenshot "MathExpr nosql-jdbc-1.0.4".
- select pets + children from contacts1
Two columns are returned: pets + children, _id.
- select pets + children as counter from contacts1
Two columns are returned: _id, pets + children.
The alias "counter" is not used in the result set.
I am using nosql-jdbc 1.0.4. The _id field is always returned with the result set when a math expression is used in the SELECT field list. See attached screenshot "MathExpr nosql-jdbc-1.0.4".
- select pets + children from contacts1
Two columns are returned: pets + children, _id.
- select pets + children as counter from contacts1
Two columns are returned: _id, pets + children.
The alias "counter" is not used in the result set.
The _id field is now hidden unless is explicitly listed on queries having math expressions. Aliases are now supported on math expressions.
The _id field is now hidden unless is explicitly listed on queries having math expressions. Aliases are now supported on math expressions.
Issue #8540 |
Closed |
Fixed |
Resolved |
Completion |
No due date |
Fixed Build nosql-jdbc 1.1.0 |
No time estimate |
We shouldn't use the MongoDB documentation (docs.mongodb.org) as our reference. We may not have full support of every function in the MongoDB syntax. We support only what makes sense in SQL syntax. We should refer to our "MongoSQL Query Reference" document to work on our documentation.
As documented in the MongoSQL Query Reference:
expr | expr
expr & expr
expr << expr
expr >> expr
expr + expr
expr – expr
expr * expr
expr / expr
expr % expr