SQL Has Problems. We Can Fix Them: Pipe Syntax In SQL - eviltoast

Really intriguing article about a SQL syntax extension that has apparently already been trialed at Google.

As someone who works with SQL for hours every week, this makes me hopeful for potential improvements, although the likelihood of any changes to SQL arriving in my sector before I retire seems slim.

  • frezik@midwest.social
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    2 months ago

    No matter which tool you’re using, this:

    - |> LEFT JOIN |> FROM foo |> GROUP BY clusterid |> SELECT clusterid, COUNT(*)
    + |> LEFT JOIN |> FROM foobar |> GROUP BY clusterid |> SELECT clusterid, COUNT(*)
          ON cluster.id = foo.clusterid
    

    Is always less readable than:

      |> LEFT JOIN 
    - |> FROM foo 
    + |> FROM foobar
      |> GROUP BY clusterid 
      |> SELECT clusterid, COUNT(*)
          ON cluster.id = foo.clusterid
    

    And this isn’t even the worst example I’ve seen. That would be a file that had a bug due to duplicated entries in a list, and it became very obvious as soon as I converted it to something akin to the second version.