-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clarification]: Clarification on Operator Precedence for SQL and NoSQL Databases #795
Comments
JDQL also defines parentheses |
Sorry by delay, I was checking this option: MongoDB does not support parentheses for grouping. Instead, MongoDB uses explicit JSON-like syntax with Redis and Cassandra do not have support for it as well. At Graph, Neo4J follows the same idea of SQL on grouping and the "AND" precedence. |
I poorly worded my reply. It should say, if you able to implement the JDQL requirements of allowing parenthesis for grouping by some underlying mechanism of the NoSQL database, then you should be able to use that same mechanism to implement precedence. So when you say:
that should be fine. MongoDB doesn't need to have syntax that matches the JDQL with parenthesis. The mechanism you said MongoDB has seems good enough to support parentheses in JDQL. For example, with this JDQL,
you can send the following to MongoDB:
Note that you could send the exact same thing to MongoDB if the query omitted the parentheses and relied upon precedence rules:
|
My point is the AND as precedence. MongoDB does not prioritize AND over OR or vice versa; the precedence is determined by the structure of the query: Let's use this query:
{
"$or":[
{
"numBitsRequired":4
},
{
"numType":"COMPOSITE"
},
{
"$and":[
{
"_id":{
"$lt":20
}
}
]
}
]
} |
No, your example above indicates a bug in your implementation. Your implementation is responsible for interpreting the precedence according to the rules of the Jakarta Data specification and translating that to the mechanism of the underlying database, which for the example above, {
"$and":[
{
"$or":[
{
"numBitsRequired":4
},
{
"numType":"COMPOSITE"
}
]
}
{
"_id":{
"$lt":20
}
}
]
} |
Thanks, but I am curious about the scope of this language, how much it should impact the database procedure or the native behavior of a database engine, and how much this SQL simulation on NoSQL could impact performance. IMHO, if the database has precedence under the order explicitly defined by the query's nesting and logical operator usage, it should not change it by language. We should embrace SQL behavior as with NoSQL and keep the boundaries of those databases. It's worth noting that Cassandra, for instance, does not support certain operations like parentheses and grouping. Understanding these limitations is crucial for effective database management. Otherwise, we need to do multiple queries and handle them by memory. While it's true that some NoSQL databases, like OrientDB and Oracle NoSQL, implement SQL language, it's important to remember that behavior may not be consistent across all NoSQL databases. This caution is necessary to avoid making assumptions that could lead to unexpected results in database management. My research is ongoing, and I'm currently considering two potential options. I value your input and look forward to discussing these options further.
|
Any impact to performance would only occur when the particular keyword or operator that you are implementing is used. So the user gets to opt in by choosing to use it if they value the function it provides. And if they choose not to use it, there should be no impact to them at all. I don't see a problem here. A vendor is free to document that certain operations might be less efficient on NoSQL if that is so, and recommend for and against whatever patterns they see fit.
Parentheses (in JDQL) and default order of precedence when parentheses are not used should be handled the same as the other differences between relational/graph/document/column/key-value. The spec should document it in terms of what the category of database is capable of, and the TCK should arrange its assertions accordingly, just as we did for the other capabilities that differ. |
Specification
https://github.com/jakartaee/data/blob/main/spec/src/main/asciidoc/query-language.asciidoc
I need clarification on ...
Please clarify or update documentation regarding the following statement:
Issue:
Request:
Thank you for your attention to this matter.
Additional information
No response
The text was updated successfully, but these errors were encountered: