You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by "Michael J. Carey (Jira)" <ji...@apache.org> on 2022/02/25 16:30:00 UTC

[jira] [Created] (ASTERIXDB-3022) Parenthetical confusion for SQL++ SOME/EVERY queries

Michael J. Carey created ASTERIXDB-3022:
-------------------------------------------

             Summary: Parenthetical confusion for SQL++ SOME/EVERY queries
                 Key: ASTERIXDB-3022
                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-3022
             Project: Apache AsterixDB
          Issue Type: Bug
          Components: COMP - Compiler, SQL - Translator SQL++
    Affects Versions: 0.9.7
            Reporter: Michael J. Carey
            Assignee: Dmitry Lychagin
             Fix For: 0.9.7


The following query works:

USE DonCData; 
SELECT VALUE o FROM orders o
WHERE (SOME i IN o.items SATISFIES i.qty > 3) AND ARRAY_COUNT(items) = 1;

But the following query doesn't work the same way (for a good but confusing reason):

USE DonCData; 
SELECT VALUE o FROM orders o
WHERE SOME i IN o.items SATISFIES i.qty > 3 AND ARRAY_COUNT(items) = 1;

In the ARRAY_COUNT call items is bound to o.items in the first query - but in the second query it is (probably) bound to i.items.  It is unclear to new SQL++ users, moving over from SQL, what's happening!  (I have seen a number of instances of this issue in teaching CS122A.)

We should (1) see about making it clearer somehow where the SOME/ALL subquery starts and ends, and (2) we should also find a way to reflect back to users what the bindings are when we are doing binding magic for unqualified references.  And for this particular query, we should also see about improving the grammar's alignment with N1QL for Query if we can, since that's a similar query language that uses an END token to address (1).



--
This message was sent by Atlassian Jira
(v8.20.1#820001)