Comment by Svip

7 years ago

The brackets make it look like they are both subqueries and contained within in the EdgeQL examples. As such, you could write the examples in SQL like this:

    SELECT count(*) + 1 FROM table

And

    SELECT *, 1 FROM table

Both of which are valid in SQL. And you'd get the same result as in the EdgeQL examples.

Indeed, a more relevant second counter example would be:

    SELECT (SELECT * FROM table) + 1

Not valid... unless `table` only had one row and one column containing a number.

Yes, and that's actually the point being made in the post. You need to rewrite your queries to make SQL happy.

  • The EdgeQL query has no obvious meaning, unless (,) calculates the cross product. Saying

    SELECT Table1, 1

    returns each row of Table1 along with 1 and that 1 returns the set {1} means that you have arbitrarily assigned each row of Table1 a row from the set {1}. This gives what you want in the case of a scalar, but what about a non-scalar.

    For example, suppose Table1 contains (John, Smith), (Alice, Perkins), (Bob, Best). Then, what should

    SELECT Table1, {1,2}

    return? If you do not say cross product, you have arbitrarily assigned rows to one another, resulting in meaningless data. If you say cross product, then you have rewritten the sql expression

    SELECT * FROM Table1, (VALUES (1), (2))

    I don't disagree the SQL syntax is longer and has some unnecessary keywords, but unlike EdgeQL, the query means something particular.

    • In EdgeQL, expressions are element-wise functions over the cross-product of the input sets:

          edgedb> SELECT {'First', 'Second'} ++ '!';
          {'First!', 'Second!'}
      

      EdgeQL queries are essentially set comprehensions.

      2 replies →

  • Is this such a common problem that you need a new language to solve it?

    • We think that people struggling with writing good/advanced SQL queries and the existence of ORMs and other heavy frameworks to make RDBMSes "friendly" is a serious problem. And inventing a a new querying language is a necessary step to make relational databases more accessible.

      1 reply →