Skip to content

Commit c5ac58e

Browse files
Revert heading structure.
1 parent 8a1b5cb commit c5ac58e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

docs-parts/queries/13-Transpiler-Design_lang1.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Moving `SELECT` to an earlier phase allows the `GROUP BY` and `HAVING` clauses t
1111
The current implementation targets the MySQL implementation where table column aliases can be used in `HAVING`.
1212
If postgres or CockroachDB cannot be coerced to work this way, restrictions of aggregations will have to be updated accordingly.
1313

14-
### QueryExpression
14+
## QueryExpression
1515
`QueryExpression` is the main object representing a distinct `SELECT` statement.
1616
It implements operators `&`, `*`, and `proj` — restriction, join, and projection.
1717

@@ -28,11 +28,11 @@ At least one element must be present in `support`. Multiple elements in `support
2828

2929
From the user's perspective `QueryExpression` objects are immutable: once created they cannot be modified. All operators derive new objects.
3030

31-
#### Alias attributes
31+
### Alias attributes
3232
`proj` can create an alias attribute by renaming an existing attribute or calculating a new attribute.
3333
Alias attributes are the primary reason why subqueries are sometimes required.
3434

35-
#### Subqueries
35+
### Subqueries
3636
Projections, restrictions, and joins do not necessarily trigger new subqueries: the resulting `QueryExpression` object simply merges the properties of its inputs into self: `heading`, `restriction`, and `support`.
3737

3838
The input object is treated as a subquery in the following cases:
@@ -48,7 +48,7 @@ An error arises if
4848

4949
A subquery is created by creating a new `QueryExpression` object (or a subclass object) with its `support` pointing to the input object.
5050

51-
#### Join compatibility
51+
### Join compatibility
5252
The join is always natural (i.e. *equijoin* on the namesake attributes).
5353

5454
**Before version 0.13:** As of version `0.12.*` and earlier, two query expressions were considered join-compatible if their namesake attributes were the primary key of at least one of the input expressions. This rule was easiest to implement but does not provide best semantics.
@@ -60,17 +60,17 @@ The join is always natural (i.e. *equijoin* on the namesake attributes).
6060

6161
The same join compatibility rules apply when restricting one query expression with another.
6262

63-
#### Join mechanics
63+
### Join mechanics
6464
Any restriction applied to the inputs of a join can be applied to its output.
6565
Therefore, those inputs that are not turned into queries donate their supports, restrictions, and projections to the join itself.
6666

67-
### Table
67+
## Table
6868
`Table` is a subclass of `QueryExpression` implementing table manipulation methods such as `insert`, `insert1`, `delete`, `update1`, and `drop`.
6969

7070
The restriction operator `&` applied to a `Table` preserves its class identity so that the result remains of type `Table`.
7171
However, `proj` converts the result into a `QueryExpression` object. This may produce a base query that is not an instance of Table.
7272

73-
### Aggregation
73+
## Aggregation
7474
`Aggregation` is a subclass of `QueryExpression`.
7575
Its main input is the *aggregating* query expression and it takes an additional second input — the *aggregated* query expression.
7676

@@ -88,7 +88,7 @@ With respect to the second input, the projection part of aggregation allows only
8888

8989
All other rules for subqueries remain the same as for `QueryExpression`
9090

91-
### Union
91+
## Union
9292
`Union` is a subclass of `QueryExpression`.
9393
A `Union` object results from the `+` operator on two `QueryExpression` objects.
9494
Its `support` property contains the list of expressions (at least two) to unify.
@@ -98,16 +98,16 @@ The `Union` operator performs an OUTER JOIN of its inputs provided that the inpu
9898

9999
Union treats all its inputs as subqueries except for unrestricted Union objects.
100100

101-
### Universal Sets `dj.U`
101+
## Universal Sets `dj.U`
102102
`dj.U` is a special operand in query expressions that allows performing special operations. By itself, it can never form a query and is not a subclass of `QueryExpression`. Other query expressions are modified through participation in operations with `dj.U`.
103103

104-
#### Aggegating by `dj.U`
104+
### Aggegating by `dj.U`
105105

106-
#### Resttricting a `dj.U` object with a `QueryExpression` object
106+
### Resttricting a `dj.U` object with a `QueryExpression` object
107107

108-
#### Joining a `dj.U` object
108+
### Joining a `dj.U` object
109109

110-
### Query "Backprojection"
110+
## Query "Backprojection"
111111
Once a QueryExpression is used in a `fetch` operation or becomes a subquery in another query, it can project out all unnecessary attributes from its own inputs, recursively.
112112
This is implemented by the `finalize` method.
113113
This simplification produces much leaner queries resulting in improved query performance in version 0.13, especially on complex queries with blob data, compensating for MySQL's deficiencies in query optimization.

0 commit comments

Comments
 (0)