Kirill Simonov avatar Kirill Simonov committed 1d2b675

Renamed `let()` to `define()`, added a few breakage tests.

Comments (0)

Files changed (7)

src/htsql/tr/binding.py

 
 class AssignmentBinding(Binding):
 
-    def __init__(self, name, replacement, syntax):
+    def __init__(self, name, body, syntax):
         assert isinstance(name, str)
-        assert isinstance(replacement, Syntax)
+        assert isinstance(body, Syntax)
         super(AssignmentBinding, self).__init__(VoidDomain(), syntax)
         self.name = name
-        self.replacement = replacement
+        self.body = body
 
 
 class LiteralBinding(Binding):

src/htsql/tr/fn/bind.py

                         ContainsSig, ExistsSig, CountSig, MinMaxSig,
                         SumSig, AvgSig, AggregateSig, QuantifySig,
                         QuotientSig, KernelSig, ComplementSig,
-                        AssignmentSig, LetSig)
+                        AssignmentSig, DefineSig)
 import sys
 
 
         yield AssignmentBinding(name, rop, self.syntax)
 
 
-class BindLet(BindMacro):
+class BindDefine(BindMacro):
 
-    named('let')
-    signature = LetSig
+    named('define')
+    signature = DefineSig
 
     def expand(self, ops):
         binding = self.state.base
             assignment = self.state.bind(op)
             if not isinstance(assignment, AssignmentBinding):
                 raise BindError("an assignment expected", op.mark)
-            replacement = self.state.bind(assignment.replacement,
-                                          base=binding)
+            body = self.state.bind(assignment.body, base=binding)
             binding = DefinitionBinding(binding, assignment.name,
-                                        replacement, self.syntax)
+                                        body, self.syntax)
         yield binding
 
 

src/htsql/tr/fn/signature.py

     pass
 
 
-class LetSig(ConnectiveSig):
+class DefineSig(ConnectiveSig):
     pass
 
 

test/regress/input/translation.yaml

     - uri: /school{name}
     - uri: /department{school.*,*}
     - uri: /department{school.name+' - '+name}
+    # Empty selectors are broken
+    - uri: /{}
+      skip: true
+    - uri: /school{}
+      skip: true
 
   # Plural links and aggregates.
   - title: Aggregates
 
   - title: Assignments
     tests:
-    - uri: /school.let(c:=department.course.credits)
+    - uri: /school.define(c:=department.course.credits)
                 {code,min(c),max(c),sum(c),avg(c)}?exists(c)
-    - uri: /school.let(program:=(program?degree='bs')
-                                .let(student:=student?is_active))
+    - uri: /school.define(program:=(program?degree='bs')
+                                .define(student:=student?is_active))
                 {code,count(program),count(program.student)}?code='eng'
     # FIXME?
     - uri: /school{code,count(program.student),
-                   count((program.let(s:=student)?degree='bs').s),
-                   count((program?degree='bs').let(s:=student).s)}?code='eng'
-    - uri: /let(x:=2,y:=3,z:=x*y){x,y,z}
-    - uri: /let(x:=2,x:=x+x,x:=x*x){x}
+                   count((program.define(s:=student)?degree='bs').s),
+                   count((program?degree='bs').define(s:=student).s)}?code='eng'
+    - uri: /define(x:=2,y:=3,z:=x*y){x,y,z}
+    - uri: /define(x:=2,x:=x+x,x:=x*x){x}
 
   - title: Projections
     tests:
     - uri: /school{code,count(program),count(program^degree)}
     - uri: /(program^degree){*,count(^),count(^.student)}
     - uri: /(student^{year(dob),gender}){*,count(^),count(^?is_active)}
+    - uri: /count(program^degree)
+    - uri: /(school^{})
+      skip: true
+    - uri: /(school^{null()})
+      skip: true
+    - uri: /(school^{true()})
+      skip: true
 

test/regress/output/mysql.yaml

                ORDER BY `school`.`code` ASC, 1 ASC
         - id: assignments
           tests:
-          - uri: /school.let(c:=department.course.credits) {code,min(c),max(c),sum(c),avg(c)}?exists(c)
-            status: 200 OK
-            headers:
-            - [Content-Type, text/plain; charset=UTF-8]
-            body: |2
-               | (school.let(c:=department.course.credits)?exists(c))               |
+          - uri: /school.define(c:=department.course.credits) {code,min(c),max(c),sum(c),avg(c)}?exists(c)
+            status: 200 OK
+            headers:
+            - [Content-Type, text/plain; charset=UTF-8]
+            body: |2
+               | (school.define(c:=department.course.credits)?exists(c))            |
               -+--------------------------------------------------------------------+-
                | code | min(c) | max(c) | sum(c) | avg(c)                           |
               -+------+--------+--------+--------+----------------------------------+-
                                                                              (6 rows)
 
                ----
-               /school.let(c:=department.course.credits){code,min(c),max(c),sum(c),avg(c)}?exists(c)
+               /school.define(c:=department.course.credits){code,min(c),max(c),sum(c),avg(c)}?exists(c)
                SELECT `school`.`code`,
                       `course`.`min`,
                       `course`.`max`,
                             WHERE (`school`.`code` = `department`.`school`)
                                   AND (`course_1`.`credits` IS NOT NULL))
                ORDER BY 1 ASC
-          - uri: /school.let(program:=(program?degree='bs') .let(student:=student?is_active))
+          - uri: /school.define(program:=(program?degree='bs') .define(student:=student?is_active))
               {code,count(program),count(program.student)}?code='eng'
             status: 200 OK
             headers:
             - [Content-Type, text/plain; charset=UTF-8]
             body: |2
-               | (school.let(program:=(program?degree='bs').let(student:=student?is_active))?code='eng') |
-              -+-----------------------------------------------------------------------------------------+-
-               | code               | count(program)               | count(program.student)              |
-              -+--------------------+------------------------------+-------------------------------------+-
-               | eng                |                            4 |                                   5 |
-                                                                                                   (1 row)
-
-               ----
-               /school.let(program:=(program?degree='bs').let(student:=student?is_active)){code,count(program),count(program.student)}?code='eng'
+               | (school.define(program:=(program?degree='bs').define(student:=student?is_active))?code='eng') |
+              -+-----------------------------------------------------------------------------------------------+-
+               | code                 | count(program)                 | count(program.student)                |
+              -+----------------------+--------------------------------+---------------------------------------+-
+               | eng                  |                              4 |                                     5 |
+                                                                                                         (1 row)
+
+               ----
+               /school.define(program:=(program?degree='bs').define(student:=student?is_active)){code,count(program),count(program.student)}?code='eng'
                SELECT `school`.`code`,
                       COALESCE(`program`.`count`, 0),
                       COALESCE(`student`.`count`, 0)
                                     ON (`school`.`code` = `student`.`school`)
                WHERE (`school`.`code` = 'eng')
                ORDER BY 1 ASC
-          - uri: /school{code,count(program.student), count((program.let(s:=student)?degree='bs').s),
-              count((program?degree='bs').let(s:=student).s)}?code='eng'
-            status: 200 OK
-            headers:
-            - [Content-Type, text/plain; charset=UTF-8]
-            body: |2
-               | (school?code='eng')                                                                                                             |
-              -+---------------------------------------------------------------------------------------------------------------------------------+-
-               | code | count(program.student) | count((program.let(s:=student)?degree='bs').s) | count((program?degree='bs').let(s:=student).s) |
-              -+------+------------------------+------------------------------------------------+------------------------------------------------+-
-               | eng  |                     14 |                                             14 |                                              6 |
-                                                                                                                                           (1 row)
-
-               ----
-               /school{code,count(program.student),count((program.let(s:=student)?degree='bs').s),count((program?degree='bs').let(s:=student).s)}?code='eng'
+          - uri: /school{code,count(program.student), count((program.define(s:=student)?degree='bs').s),
+              count((program?degree='bs').define(s:=student).s)}?code='eng'
+            status: 200 OK
+            headers:
+            - [Content-Type, text/plain; charset=UTF-8]
+            body: |2
+               | (school?code='eng')                                                                                                                   |
+              -+---------------------------------------------------------------------------------------------------------------------------------------+-
+               | code | count(program.student) | count((program.define(s:=student)?degree='bs').s) | count((program?degree='bs').define(s:=student).s) |
+              -+------+------------------------+---------------------------------------------------+---------------------------------------------------+-
+               | eng  |                     14 |                                                14 |                                                 6 |
+                                                                                                                                                 (1 row)
+
+               ----
+               /school{code,count(program.student),count((program.define(s:=student)?degree='bs').s),count((program?degree='bs').define(s:=student).s)}?code='eng'
                SELECT `school`.`code`,
                       COALESCE(`student_1`.`count`, 0),
                       COALESCE(`student_1`.`count`, 0),
                                     ON (`school`.`code` = `student_2`.`school`)
                WHERE (`school`.`code` = 'eng')
                ORDER BY 1 ASC
-          - uri: /let(x:=2,y:=3,z:=x*y){x,y,z}
-            status: 200 OK
-            headers:
-            - [Content-Type, text/plain; charset=UTF-8]
-            body: |2
-               | let(x:=2,y:=3,z:=x*y) |
-              -+-----------------------+-
-               | x     | y     | z     |
-              -+-------+-------+-------+-
-               |     2 |     3 |     6 |
-                                 (1 row)
-
-               ----
-               /let(x:=2,y:=3,z:=x*y){x,y,z}
+          - uri: /define(x:=2,y:=3,z:=x*y){x,y,z}
+            status: 200 OK
+            headers:
+            - [Content-Type, text/plain; charset=UTF-8]
+            body: |2
+               | define(x:=2,y:=3,z:=x*y) |
+              -+--------------------------+-
+               | x      | y      | z      |
+              -+--------+--------+--------+-
+               |      2 |      3 |      6 |
+                                    (1 row)
+
+               ----
+               /define(x:=2,y:=3,z:=x*y){x,y,z}
                SELECT 2,
                       3,
                       (2 * 3)
-          - uri: /let(x:=2,x:=x+x,x:=x*x){x}
-            status: 200 OK
-            headers:
-            - [Content-Type, text/plain; charset=UTF-8]
-            body: |2
-               | let(x:=2,x:=x+x,x:=x*x) |
-              -+-------------------------+-
-               | x                       |
-              -+-------------------------+-
-               |                      16 |
-                                   (1 row)
-
-               ----
-               /let(x:=2,x:=x+x,x:=x*x){x}
+          - uri: /define(x:=2,x:=x+x,x:=x*x){x}
+            status: 200 OK
+            headers:
+            - [Content-Type, text/plain; charset=UTF-8]
+            body: |2
+               | define(x:=2,x:=x+x,x:=x*x) |
+              -+----------------------------+-
+               | x                          |
+              -+----------------------------+-
+               |                         16 |
+                                      (1 row)
+
+               ----
+               /define(x:=2,x:=x+x,x:=x*x){x}
                SELECT ((2 + 2) * (2 + 2))
         - id: projections
           tests:
                                      GROUP BY 2, 3) AS `student_3`
                                     ON ((`student_1`.`year` = `student_3`.`year`) AND (`student_1`.`gender` = `student_3`.`gender`))
                ORDER BY 1 ASC, 2 ASC
+          - uri: /count(program^degree)
+            status: 200 OK
+            headers:
+            - [Content-Type, text/plain; charset=UTF-8]
+            body: |2
+               |                       |
+              -+-----------------------+-
+               | count(program^degree) |
+              -+-----------------------+-
+               |                     8 |
+                                 (1 row)
+
+               ----
+               /count(program^degree)
+               SELECT COUNT(TRUE)
+               FROM (SELECT TRUE AS `^`
+                     FROM `htsql_regress`.`program` AS `program`
+                     GROUP BY `program`.`degree`) AS `program`
   - include: test/regress/input/format.yaml
     output:
       id: format

test/regress/output/pgsql.yaml

                ORDER BY "school"."code" ASC, 1 ASC
         - id: assignments
           tests:
-          - uri: /school.let(c:=department.course.credits) {code,min(c),max(c),sum(c),avg(c)}?exists(c)
-            status: 200 OK
-            headers:
-            - [Content-Type, text/plain; charset=UTF-8]
-            body: |2
-               | (school.let(c:=department.course.credits)?exists(c)) |
-              -+------------------------------------------------------+-
-               | code | min(c) | max(c) | sum(c) | avg(c)             |
-              -+------+--------+--------+--------+--------------------+-
-               | art  |      0 |      5 |     38 | 3.1666666666666667 |
-               | bus  |      2 |      5 |     40 | 3.0769230769230769 |
-               | edu  |      3 |      4 |     28 | 3.1111111111111111 |
-               | eng  |      3 |      8 |     72 | 3.4285714285714286 |
-               | la   |      2 |      4 |     82 | 3.0370370370370370 |
-               | ns   |      1 |      5 |     45 | 2.8125000000000000 |
-                                                               (6 rows)
-
-               ----
-               /school.let(c:=department.course.credits){code,min(c),max(c),sum(c),avg(c)}?exists(c)
+          - uri: /school.define(c:=department.course.credits) {code,min(c),max(c),sum(c),avg(c)}?exists(c)
+            status: 200 OK
+            headers:
+            - [Content-Type, text/plain; charset=UTF-8]
+            body: |2
+               | (school.define(c:=department.course.credits)?exists(c)) |
+              -+---------------------------------------------------------+-
+               | code  | min(c)  | max(c)  | sum(c) | avg(c)             |
+              -+-------+---------+---------+--------+--------------------+-
+               | art   |       0 |       5 |     38 | 3.1666666666666667 |
+               | bus   |       2 |       5 |     40 | 3.0769230769230769 |
+               | edu   |       3 |       4 |     28 | 3.1111111111111111 |
+               | eng   |       3 |       8 |     72 | 3.4285714285714286 |
+               | la    |       2 |       4 |     82 | 3.0370370370370370 |
+               | ns    |       1 |       5 |     45 | 2.8125000000000000 |
+                                                                  (6 rows)
+
+               ----
+               /school.define(c:=department.course.credits){code,min(c),max(c),sum(c),avg(c)}?exists(c)
                SELECT "school"."code",
                       "course"."min",
                       "course"."max",
                             WHERE ("school"."code" = "department"."school")
                                   AND ("course_1"."credits" IS NOT NULL))
                ORDER BY 1 ASC
-          - uri: /school.let(program:=(program?degree='bs') .let(student:=student?is_active))
+          - uri: /school.define(program:=(program?degree='bs') .define(student:=student?is_active))
               {code,count(program),count(program.student)}?code='eng'
             status: 200 OK
             headers:
             - [Content-Type, text/plain; charset=UTF-8]
             body: |2
-               | (school.let(program:=(program?degree='bs').let(student:=student?is_active))?code='eng') |
-              -+-----------------------------------------------------------------------------------------+-
-               | code               | count(program)               | count(program.student)              |
-              -+--------------------+------------------------------+-------------------------------------+-
-               | eng                |                            4 |                                   5 |
-                                                                                                   (1 row)
-
-               ----
-               /school.let(program:=(program?degree='bs').let(student:=student?is_active)){code,count(program),count(program.student)}?code='eng'
+               | (school.define(program:=(program?degree='bs').define(student:=student?is_active))?code='eng') |
+              -+-----------------------------------------------------------------------------------------------+-
+               | code                 | count(program)                 | count(program.student)                |
+              -+----------------------+--------------------------------+---------------------------------------+-
+               | eng                  |                              4 |                                     5 |
+                                                                                                         (1 row)
+
+               ----
+               /school.define(program:=(program?degree='bs').define(student:=student?is_active)){code,count(program),count(program.student)}?code='eng'
                SELECT "school"."code",
                       COALESCE("program"."count", 0),
                       COALESCE("student"."count", 0)
                                     ON ("school"."code" = "student"."school")
                WHERE ("school"."code" = 'eng')
                ORDER BY 1 ASC
-          - uri: /school{code,count(program.student), count((program.let(s:=student)?degree='bs').s),
-              count((program?degree='bs').let(s:=student).s)}?code='eng'
-            status: 200 OK
-            headers:
-            - [Content-Type, text/plain; charset=UTF-8]
-            body: |2
-               | (school?code='eng')                                                                                                             |
-              -+---------------------------------------------------------------------------------------------------------------------------------+-
-               | code | count(program.student) | count((program.let(s:=student)?degree='bs').s) | count((program?degree='bs').let(s:=student).s) |
-              -+------+------------------------+------------------------------------------------+------------------------------------------------+-
-               | eng  |                     14 |                                             14 |                                              6 |
-                                                                                                                                           (1 row)
-
-               ----
-               /school{code,count(program.student),count((program.let(s:=student)?degree='bs').s),count((program?degree='bs').let(s:=student).s)}?code='eng'
+          - uri: /school{code,count(program.student), count((program.define(s:=student)?degree='bs').s),
+              count((program?degree='bs').define(s:=student).s)}?code='eng'
+            status: 200 OK
+            headers:
+            - [Content-Type, text/plain; charset=UTF-8]
+            body: |2
+               | (school?code='eng')                                                                                                                   |
+              -+---------------------------------------------------------------------------------------------------------------------------------------+-
+               | code | count(program.student) | count((program.define(s:=student)?degree='bs').s) | count((program?degree='bs').define(s:=student).s) |
+              -+------+------------------------+---------------------------------------------------+---------------------------------------------------+-
+               | eng  |                     14 |                                                14 |                                                 6 |
+                                                                                                                                                 (1 row)
+
+               ----
+               /school{code,count(program.student),count((program.define(s:=student)?degree='bs').s),count((program?degree='bs').define(s:=student).s)}?code='eng'
                SELECT "school"."code",
                       COALESCE("student_1"."count", 0),
                       COALESCE("student_1"."count", 0),
                                     ON ("school"."code" = "student_2"."school")
                WHERE ("school"."code" = 'eng')
                ORDER BY 1 ASC
-          - uri: /let(x:=2,y:=3,z:=x*y){x,y,z}
-            status: 200 OK
-            headers:
-            - [Content-Type, text/plain; charset=UTF-8]
-            body: |2
-               | let(x:=2,y:=3,z:=x*y) |
-              -+-----------------------+-
-               | x     | y     | z     |
-              -+-------+-------+-------+-
-               |     2 |     3 |     6 |
-                                 (1 row)
-
-               ----
-               /let(x:=2,y:=3,z:=x*y){x,y,z}
+          - uri: /define(x:=2,y:=3,z:=x*y){x,y,z}
+            status: 200 OK
+            headers:
+            - [Content-Type, text/plain; charset=UTF-8]
+            body: |2
+               | define(x:=2,y:=3,z:=x*y) |
+              -+--------------------------+-
+               | x      | y      | z      |
+              -+--------+--------+--------+-
+               |      2 |      3 |      6 |
+                                    (1 row)
+
+               ----
+               /define(x:=2,y:=3,z:=x*y){x,y,z}
                SELECT 2,
                       3,
                       (2 * 3)
-          - uri: /let(x:=2,x:=x+x,x:=x*x){x}
-            status: 200 OK
-            headers:
-            - [Content-Type, text/plain; charset=UTF-8]
-            body: |2
-               | let(x:=2,x:=x+x,x:=x*x) |
-              -+-------------------------+-
-               | x                       |
-              -+-------------------------+-
-               |                      16 |
-                                   (1 row)
-
-               ----
-               /let(x:=2,x:=x+x,x:=x*x){x}
+          - uri: /define(x:=2,x:=x+x,x:=x*x){x}
+            status: 200 OK
+            headers:
+            - [Content-Type, text/plain; charset=UTF-8]
+            body: |2
+               | define(x:=2,x:=x+x,x:=x*x) |
+              -+----------------------------+-
+               | x                          |
+              -+----------------------------+-
+               |                         16 |
+                                      (1 row)
+
+               ----
+               /define(x:=2,x:=x+x,x:=x*x){x}
                SELECT ((2 + 2) * (2 + 2))
         - id: projections
           tests:
                                      GROUP BY 2, 3) AS "student_3"
                                     ON (("student_1"."year" = "student_3"."year") AND ("student_1"."gender" = "student_3"."gender"))
                ORDER BY 1 ASC, 2 ASC
+          - uri: /count(program^degree)
+            status: 200 OK
+            headers:
+            - [Content-Type, text/plain; charset=UTF-8]
+            body: |2
+               |                       |
+              -+-----------------------+-
+               | count(program^degree) |
+              -+-----------------------+-
+               |                     8 |
+                                 (1 row)
+
+               ----
+               /count(program^degree)
+               SELECT COUNT(TRUE)
+               FROM (SELECT TRUE AS "^"
+                     FROM "ad"."program" AS "program"
+                     GROUP BY "program"."degree") AS "program"
   - include: test/regress/input/format.yaml
     output:
       id: format

test/regress/output/sqlite.yaml

                ORDER BY "school"."code" ASC, 1 ASC
         - id: assignments
           tests:
-          - uri: /school.let(c:=department.course.credits) {code,min(c),max(c),sum(c),avg(c)}?exists(c)
-            status: 200 OK
-            headers:
-            - [Content-Type, text/plain; charset=UTF-8]
-            body: |2
-               | (school.let(c:=department.course.credits)?exists(c)) |
-              -+------------------------------------------------------+-
-               | code  | min(c)  | max(c)  | sum(c)  | avg(c)         |
-              -+-------+---------+---------+---------+----------------+-
-               | art   |       0 |       5 |      38 |  3.16666666667 |
-               | bus   |       2 |       5 |      40 |  3.07692307692 |
-               | edu   |       3 |       4 |      28 |  3.11111111111 |
-               | eng   |       3 |       8 |      72 |  3.42857142857 |
-               | la    |       2 |       4 |      82 |  3.03703703704 |
-               | ns    |       1 |       5 |      45 |         2.8125 |
-                                                               (6 rows)
-
-               ----
-               /school.let(c:=department.course.credits){code,min(c),max(c),sum(c),avg(c)}?exists(c)
+          - uri: /school.define(c:=department.course.credits) {code,min(c),max(c),sum(c),avg(c)}?exists(c)
+            status: 200 OK
+            headers:
+            - [Content-Type, text/plain; charset=UTF-8]
+            body: |2
+               | (school.define(c:=department.course.credits)?exists(c)) |
+              -+---------------------------------------------------------+-
+               | code   | min(c)   | max(c)   | sum(c)  | avg(c)         |
+              -+--------+----------+----------+---------+----------------+-
+               | art    |        0 |        5 |      38 |  3.16666666667 |
+               | bus    |        2 |        5 |      40 |  3.07692307692 |
+               | edu    |        3 |        4 |      28 |  3.11111111111 |
+               | eng    |        3 |        8 |      72 |  3.42857142857 |
+               | la     |        2 |        4 |      82 |  3.03703703704 |
+               | ns     |        1 |        5 |      45 |         2.8125 |
+                                                                  (6 rows)
+
+               ----
+               /school.define(c:=department.course.credits){code,min(c),max(c),sum(c),avg(c)}?exists(c)
                SELECT "school"."code",
                       "course"."min",
                       "course"."max",
                             WHERE ("school"."code" = "department"."school")
                                   AND ("course_1"."credits" IS NOT NULL))
                ORDER BY 1 ASC
-          - uri: /school.let(program:=(program?degree='bs') .let(student:=student?is_active))
+          - uri: /school.define(program:=(program?degree='bs') .define(student:=student?is_active))
               {code,count(program),count(program.student)}?code='eng'
             status: 200 OK
             headers:
             - [Content-Type, text/plain; charset=UTF-8]
             body: |2
-               | (school.let(program:=(program?degree='bs').let(student:=student?is_active))?code='eng') |
-              -+-----------------------------------------------------------------------------------------+-
-               | code               | count(program)               | count(program.student)              |
-              -+--------------------+------------------------------+-------------------------------------+-
-               | eng                |                            4 |                                   5 |
-                                                                                                   (1 row)
-
-               ----
-               /school.let(program:=(program?degree='bs').let(student:=student?is_active)){code,count(program),count(program.student)}?code='eng'
+               | (school.define(program:=(program?degree='bs').define(student:=student?is_active))?code='eng') |
+              -+-----------------------------------------------------------------------------------------------+-
+               | code                 | count(program)                 | count(program.student)                |
+              -+----------------------+--------------------------------+---------------------------------------+-
+               | eng                  |                              4 |                                     5 |
+                                                                                                         (1 row)
+
+               ----
+               /school.define(program:=(program?degree='bs').define(student:=student?is_active)){code,count(program),count(program.student)}?code='eng'
                SELECT "school"."code",
                       COALESCE("program"."count", 0),
                       COALESCE("student"."count", 0)
                                     ON ("school"."code" = "student"."school")
                WHERE ("school"."code" = 'eng')
                ORDER BY 1 ASC
-          - uri: /school{code,count(program.student), count((program.let(s:=student)?degree='bs').s),
-              count((program?degree='bs').let(s:=student).s)}?code='eng'
-            status: 200 OK
-            headers:
-            - [Content-Type, text/plain; charset=UTF-8]
-            body: |2
-               | (school?code='eng')                                                                                                             |
-              -+---------------------------------------------------------------------------------------------------------------------------------+-
-               | code | count(program.student) | count((program.let(s:=student)?degree='bs').s) | count((program?degree='bs').let(s:=student).s) |
-              -+------+------------------------+------------------------------------------------+------------------------------------------------+-
-               | eng  |                     14 |                                             14 |                                              6 |
-                                                                                                                                           (1 row)
-
-               ----
-               /school{code,count(program.student),count((program.let(s:=student)?degree='bs').s),count((program?degree='bs').let(s:=student).s)}?code='eng'
+          - uri: /school{code,count(program.student), count((program.define(s:=student)?degree='bs').s),
+              count((program?degree='bs').define(s:=student).s)}?code='eng'
+            status: 200 OK
+            headers:
+            - [Content-Type, text/plain; charset=UTF-8]
+            body: |2
+               | (school?code='eng')                                                                                                                   |
+              -+---------------------------------------------------------------------------------------------------------------------------------------+-
+               | code | count(program.student) | count((program.define(s:=student)?degree='bs').s) | count((program?degree='bs').define(s:=student).s) |
+              -+------+------------------------+---------------------------------------------------+---------------------------------------------------+-
+               | eng  |                     14 |                                                14 |                                                 6 |
+                                                                                                                                                 (1 row)
+
+               ----
+               /school{code,count(program.student),count((program.define(s:=student)?degree='bs').s),count((program?degree='bs').define(s:=student).s)}?code='eng'
                SELECT "school"."code",
                       COALESCE("student_1"."count", 0),
                       COALESCE("student_1"."count", 0),
                                     ON ("school"."code" = "student_2"."school")
                WHERE ("school"."code" = 'eng')
                ORDER BY 1 ASC
-          - uri: /let(x:=2,y:=3,z:=x*y){x,y,z}
-            status: 200 OK
-            headers:
-            - [Content-Type, text/plain; charset=UTF-8]
-            body: |2
-               | let(x:=2,y:=3,z:=x*y) |
-              -+-----------------------+-
-               | x     | y     | z     |
-              -+-------+-------+-------+-
-               |     2 |     3 |     6 |
-                                 (1 row)
-
-               ----
-               /let(x:=2,y:=3,z:=x*y){x,y,z}
+          - uri: /define(x:=2,y:=3,z:=x*y){x,y,z}
+            status: 200 OK
+            headers:
+            - [Content-Type, text/plain; charset=UTF-8]
+            body: |2
+               | define(x:=2,y:=3,z:=x*y) |
+              -+--------------------------+-
+               | x      | y      | z      |
+              -+--------+--------+--------+-
+               |      2 |      3 |      6 |
+                                    (1 row)
+
+               ----
+               /define(x:=2,y:=3,z:=x*y){x,y,z}
                SELECT 2,
                       3,
                       (2 * 3)
-          - uri: /let(x:=2,x:=x+x,x:=x*x){x}
-            status: 200 OK
-            headers:
-            - [Content-Type, text/plain; charset=UTF-8]
-            body: |2
-               | let(x:=2,x:=x+x,x:=x*x) |
-              -+-------------------------+-
-               | x                       |
-              -+-------------------------+-
-               |                      16 |
-                                   (1 row)
-
-               ----
-               /let(x:=2,x:=x+x,x:=x*x){x}
+          - uri: /define(x:=2,x:=x+x,x:=x*x){x}
+            status: 200 OK
+            headers:
+            - [Content-Type, text/plain; charset=UTF-8]
+            body: |2
+               | define(x:=2,x:=x+x,x:=x*x) |
+              -+----------------------------+-
+               | x                          |
+              -+----------------------------+-
+               |                         16 |
+                                      (1 row)
+
+               ----
+               /define(x:=2,x:=x+x,x:=x*x){x}
                SELECT ((2 + 2) * (2 + 2))
         - id: projections
           tests:
                                      GROUP BY 2, 3) AS "student_3"
                                     ON (("student_1"."year" = "student_3"."year") AND ("student_1"."gender" = "student_3"."gender"))
                ORDER BY 1 ASC, 2 ASC
+          - uri: /count(program^degree)
+            status: 200 OK
+            headers:
+            - [Content-Type, text/plain; charset=UTF-8]
+            body: |2
+               |                       |
+              -+-----------------------+-
+               | count(program^degree) |
+              -+-----------------------+-
+               |                     8 |
+                                 (1 row)
+
+               ----
+               /count(program^degree)
+               SELECT COUNT(1)
+               FROM (SELECT 1 AS "^"
+                     FROM "program" AS "program"
+                     GROUP BY "program"."degree") AS "program"
   - include: test/regress/input/format.yaml
     output:
       id: format
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.