Skip to content

Commit 889f155

Browse files
committed
Merge remote-tracking branch 'upstream/main' into vector-simd
2 parents 8734bc2 + bbe9986 commit 889f155

18 files changed

Lines changed: 1052 additions & 90 deletions

File tree

docs/sphinx/source/ReleaseNotes.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,90 @@ As the [versioning guide](Versioning.md) details, it cannot always be determined
77

88
## 4.12
99

10+
### 4.12.10.0
11+
12+
<h4> New Features </h4>
13+
14+
* Define sliding window counters and timing events - [PR #4278](https://github.com/FoundationDB/fdb-record-layer/pull/4278)
15+
* Allow table name as column reference to return row as struct (`SELECT t from t`) - [PR #4195](https://github.com/FoundationDB/fdb-record-layer/pull/4195)
16+
17+
<details>
18+
<summary>
19+
20+
<h4> Build/Test/Documentation/Style Improvements (click to expand) </h4>
21+
22+
</summary>
23+
24+
* Add CREATE VIEW documentation - [PR #4208](https://github.com/FoundationDB/fdb-record-layer/pull/4208)
25+
26+
</details>
27+
28+
29+
**[Full Changelog (4.12.9.0...4.12.10.0)](https://github.com/FoundationDB/fdb-record-layer/compare/4.12.9.0...4.12.10.0)**
30+
31+
#### Mixed Mode Test Results
32+
33+
Mixed mode testing run against the following previous versions:
34+
35+
`4.11.1.0`, ✅`4.12.1.0`, ✅`4.12.2.0`, ✅`4.12.3.0`, ✅`4.12.4.0`, ✅`4.12.5.0`, ✅`4.12.6.0`, ✅`4.12.7.0`, ✅`4.12.8.0`, ✅`4.12.9.0`
36+
37+
[See full test run](https://github.com/FoundationDB/fdb-record-layer/actions/runs/27360184639)
38+
39+
40+
41+
### 4.12.9.0
42+
43+
<h4> Breaking Changes </h4>
44+
45+
* Disallow `LEFT` and `RIGHT` as simple identifiers in the SQL grammar - [PR #4272](https://github.com/FoundationDB/fdb-record-layer/pull/4272)
46+
<h4> New Features </h4>
47+
48+
* Don’t generate unnecessary casts in `CastValue.inject()` - [PR #4252](https://github.com/FoundationDB/fdb-record-layer/pull/4252)
49+
* kmeans package - [PR #4203](https://github.com/FoundationDB/fdb-record-layer/pull/4203)
50+
* Indexer: fix typed records optimization - [PR #4244](https://github.com/FoundationDB/fdb-record-layer/pull/4244)
51+
<h4> Bug Fixes </h4>
52+
53+
* Make the null-supplying side of `OUTER JOIN` nullable in the result value - [PR #4274](https://github.com/FoundationDB/fdb-record-layer/pull/4274)
54+
* Fail if metrics are missing for a query in yaml-tests - [PR #4194](https://github.com/FoundationDB/fdb-record-layer/pull/4194)
55+
* Fix an unreachable `if` branch in `QueryPredicateSimplificationRule` - [PR #4257](https://github.com/FoundationDB/fdb-record-layer/pull/4257)
56+
<h4> Performance Improvements </h4>
57+
58+
* Removed a check from `checkVersion` that would clear the `omit_unsplit_record_suffix` on empty stores - [PR #4277](https://github.com/FoundationDB/fdb-record-layer/pull/4277)
59+
* Enable efficient rule-index-based matching for `AbsorptionRule` - [PR #4255](https://github.com/FoundationDB/fdb-record-layer/pull/4255)
60+
* Remove a dead call to `Simplification.optimize()` from `VectorIndexExpansionVisitor` - [PR #4256](https://github.com/FoundationDB/fdb-record-layer/pull/4256)
61+
<h4> Dependency Updates </h4>
62+
63+
* Add a dependabot.yml to enable automatic dependency updates - [PR #4250](https://github.com/FoundationDB/fdb-record-layer/pull/4250)
64+
65+
<details>
66+
<summary>
67+
68+
<h4> Build/Test/Documentation/Style Improvements (click to expand) </h4>
69+
70+
</summary>
71+
72+
* improve numerical stability of test - [PR #4276](https://github.com/FoundationDB/fdb-record-layer/pull/4276)
73+
* Update some Gradle plugins and remove the `com.github.ben-manes.versions` plugin - [PR #4267](https://github.com/FoundationDB/fdb-record-layer/pull/4267)
74+
* Expand the SQL documentation for ARRAY unnesting - [PR #4271](https://github.com/FoundationDB/fdb-record-layer/pull/4271)
75+
* Harden GitHub Actions security posture - [PR #4249](https://github.com/FoundationDB/fdb-record-layer/pull/4249)
76+
* Raise the `maxHeapSize` from 512 MB to 4 GB on Gradle `Test` tasks - [PR #4265](https://github.com/FoundationDB/fdb-record-layer/pull/4265)
77+
* Delete `FoldConstantRule` - [PR #4259](https://github.com/FoundationDB/fdb-record-layer/pull/4259)
78+
79+
</details>
80+
81+
82+
**[Full Changelog (4.12.8.0...4.12.9.0)](https://github.com/FoundationDB/fdb-record-layer/compare/4.12.8.0...4.12.9.0)**
83+
84+
#### Mixed Mode Test Results
85+
86+
Mixed mode testing run against the following previous versions:
87+
88+
`4.10.20.0`, ✅`4.11.1.0`, ✅`4.12.1.0`, ✅`4.12.2.0`, ✅`4.12.3.0`, ✅`4.12.4.0`, ✅`4.12.5.0`, ✅`4.12.6.0`, ✅`4.12.7.0`, ✅`4.12.8.0`
89+
90+
[See full test run](https://github.com/FoundationDB/fdb-record-layer/actions/runs/27294965829)
91+
92+
93+
1094
### 4.12.8.0
1195

1296
<h4> New Features </h4>

docs/sphinx/source/reference/sql_commands/DDL/CREATE.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ CREATE
1313
CREATE/INDEX
1414
CREATE/FUNCTION
1515
CREATE/TEMPORARY_FUNCTION
16+
CREATE/VIEW

docs/sphinx/source/reference/sql_commands/DDL/CREATE/FUNCTION.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,4 @@ See Also
308308

309309
* :ref:`Subqueries <subqueries>` - Using functions in subqueries
310310
* :ref:`Joins <joins>` - Using functions in join operations
311+
* :ref:`CREATE VIEW <create-view>` - Views: reusable queries without parameters

docs/sphinx/source/reference/sql_commands/DDL/CREATE/INDEX.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ ORDER BY clause:
279279
- Expressions in GROUP BY are supported
280280
- WHERE clauses can be used with aggregate indexes for filtered aggregates
281281

282+
.. _index-on-syntax:
283+
282284
INDEX ON Syntax
283285
===============
284286

@@ -361,6 +363,21 @@ First define a view with the filter:
361363
362364
CREATE INDEX idx_expensive_products ON v_expensive_products(price)
363365
366+
**Index on View (Array Unnesting)**
367+
368+
A common pattern is to create a view that unnests an array column, then index the result. This creates a self-contained schema template with the table, view, and index together:
369+
370+
.. code-block:: sql
371+
372+
CREATE SCHEMA TEMPLATE my_template
373+
CREATE TABLE products (
374+
id BIGINT,
375+
tags STRING ARRAY,
376+
PRIMARY KEY(id))
377+
CREATE VIEW product_tags AS
378+
SELECT SQ.tag FROM products AS p, (SELECT tag FROM p.tags AS tag) AS SQ
379+
CREATE INDEX idx_tags ON product_tags (tag)
380+
364381
**Custom Ordering**
365382

366383
.. code-block:: sql

docs/sphinx/source/reference/sql_commands/DDL/CREATE/SCHEMA_TEMPLATE.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
.. _create-schema-template:
2+
13
======================
24
CREATE SCHEMA TEMPLATE
35
======================
46

5-
.. _create-schema-template:
6-
7-
A schema template is a predefined structure that defines the set of ``TABLE`` and ``INDEX`` definitions. This can then
8-
used as a blueprint to create ``SCHEMA`` in a database. See: :doc:`../../../Databases_Schemas_SchemaTemplates` for more
9-
information.
7+
A schema template is a predefined structure that defines a set of ``TABLE``, ``INDEX``, ``VIEW``, ``TYPE``, and
8+
``FUNCTION`` definitions. It can then be used as a blueprint to create ``SCHEMA`` instances in a database.
9+
See: :doc:`../../../Databases_Schemas_SchemaTemplates` for more information.
1010

1111
Syntax
1212
======

docs/sphinx/source/reference/sql_commands/DDL/CREATE/TABLE.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,9 @@ Attempting to insert a second row in a :sql:`SINGLE ROW ONLY` table will result
109109
* - :sql:`NULL`
110110
- :json:`0.0`
111111
- :json:`"X"`
112+
113+
See Also
114+
========
115+
116+
* :ref:`CREATE VIEW <create-view>` — Virtual (non-materialized) tables defined by a query
117+
* :doc:`INDEX` — Defining indexes on tables and views
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Diagram(
2+
Sequence(
3+
Terminal('CREATE'),
4+
Terminal('VIEW'),
5+
NonTerminal('viewName'),
6+
Terminal('AS'),
7+
NonTerminal('query')
8+
)
9+
)
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
===========
2+
CREATE VIEW
3+
===========
4+
5+
.. _create-view:
6+
7+
Clause in a :ref:`schema template definition <create-schema-template>` to create a non-materialized view. A view is a virtual table whose contents are defined by a SQL query. Views do not store data themselves; each query against a view executes the underlying query against the base tables. Views are read-only and cannot be the target of ``INSERT``, ``UPDATE``, or ``DELETE`` statements. ``CREATE VIEW`` is a clause within a schema template and cannot be a standalone statement. View names must not collide with table, type, or function names in the same schema template.
8+
9+
Syntax
10+
======
11+
12+
.. raw:: html
13+
:file: VIEW.diagram.svg
14+
15+
Parameters
16+
==========
17+
18+
``viewName``
19+
The name of the view. Must be unique within the schema template — cannot collide with table, type, or other view names.
20+
21+
``query``
22+
The SQL ``SELECT`` statement that defines the view. The query can reference tables, other views, and functions defined in the same schema template.
23+
24+
Examples
25+
========
26+
27+
Setup
28+
-----
29+
30+
``CREATE VIEW`` must appear inside a :ref:`schema template <create-schema-template>` definition and cannot be a standalone statement. For the examples on this page, assume the following schema template:
31+
32+
.. code-block:: sql
33+
34+
CREATE SCHEMA TEMPLATE my_template
35+
CREATE TABLE employees (
36+
id BIGINT,
37+
name STRING,
38+
dept STRING,
39+
salary BIGINT,
40+
PRIMARY KEY(id))
41+
42+
Basic View
43+
----------
44+
45+
Create a view that filters rows from a base table:
46+
47+
.. code-block:: sql
48+
49+
CREATE VIEW engineering AS
50+
SELECT id, name, salary
51+
FROM employees
52+
WHERE dept = 'Engineering'
53+
54+
Query the view like a table:
55+
56+
.. code-block:: sql
57+
58+
SELECT * FROM engineering
59+
60+
.. list-table::
61+
:header-rows: 1
62+
63+
* - :sql:`id`
64+
- :sql:`name`
65+
- :sql:`salary`
66+
* - :json:`1`
67+
- :json:`"Alice"`
68+
- :json:`100000`
69+
* - :json:`2`
70+
- :json:`"Bob"`
71+
- :json:`110000`
72+
73+
Nested Views
74+
------------
75+
76+
Views can reference other views. The following creates a second view on top of the first:
77+
78+
.. code-block:: sql
79+
80+
CREATE VIEW engineering AS
81+
SELECT id, name, salary
82+
FROM employees
83+
WHERE dept = 'Engineering'
84+
85+
CREATE VIEW high_earners AS
86+
SELECT id, name
87+
FROM engineering
88+
WHERE salary > 100000
89+
90+
.. code-block:: sql
91+
92+
SELECT * FROM high_earners
93+
94+
.. list-table::
95+
:header-rows: 1
96+
97+
* - :sql:`id`
98+
- :sql:`name`
99+
* - :json:`2`
100+
- :json:`"Bob"`
101+
102+
View with JOIN
103+
--------------
104+
105+
Views support joins, including self-joins (see :ref:`inner_join` for join syntax):
106+
107+
.. code-block:: sql
108+
109+
CREATE VIEW peer_pairs AS
110+
SELECT A.name AS emp1, B.name AS emp2
111+
FROM employees A, employees B
112+
WHERE A.dept = B.dept AND A.id < B.id
113+
114+
View with CTE
115+
-------------
116+
117+
Views can use Common Table Expressions (see :doc:`WITH` for CTE syntax):
118+
119+
.. code-block:: sql
120+
121+
CREATE VIEW senior_engineering AS
122+
WITH filtered AS (
123+
SELECT id, name, salary
124+
FROM employees
125+
WHERE dept = 'Engineering' AND salary > 100000
126+
)
127+
SELECT * FROM filtered
128+
129+
Indexes on Views
130+
----------------
131+
132+
Indexes can be defined on views using the standard ``CREATE INDEX`` syntax. For a self-contained example including array unnesting, see :ref:`index-on-syntax` in :doc:`INDEX`.
133+
134+
See Also
135+
========
136+
137+
* :ref:`create-schema-template` — Schema templates and their clauses
138+
* :doc:`TABLE` — Defining tables within a schema template
139+
* :doc:`INDEX` — Defining indexes, including :ref:`index-on-syntax` for indexes on views
140+
* :doc:`FUNCTION` — User-defined functions

docs/sphinx/source/reference/sql_commands/DQL/SELECT.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,56 @@ It is also possible to project individual columns from a table, for example, sup
113113
* - :json:`"Restaurant4"`
114114

115115

116+
Projecting the entire row as a struct
117+
-------------------------------------
118+
119+
It is possible to project the entire row as a single :sql:`STRUCT` column rather than expanding individual fields. There are two equivalent ways to do this.
120+
121+
**Using** :sql:`(*)`
122+
123+
.. code-block:: sql
124+
125+
SELECT (*) FROM restaurant;
126+
127+
This returns one column per row, named after the table, whose value is a :sql:`STRUCT` containing all of the table's fields:
128+
129+
.. list-table::
130+
:header-rows: 1
131+
132+
* - :sql:`restaurant`
133+
* - :json:`{"REST_NO": 42, "NAME": "Restaurant1", "REVIEWS": [...]}`
134+
* - :json:`{"REST_NO": 43, "NAME": "Restaurant2", "REVIEWS": [...]}`
135+
* - :json:`{"REST_NO": 44, "NAME": "Restaurant3", "REVIEWS": [...]}`
136+
* - :json:`{"REST_NO": 45, "NAME": "Restaurant4", "REVIEWS": [...]}`
137+
138+
**Using the table name (or alias) as the projection expression**
139+
140+
As a shorthand, using the table name directly in the :sql:`SELECT` list is equivalent to :sql:`SELECT (*)`:
141+
142+
.. code-block:: sql
143+
144+
SELECT restaurant FROM restaurant;
145+
146+
If the table has an alias, use the alias:
147+
148+
.. code-block:: sql
149+
150+
SELECT r FROM restaurant r;
151+
152+
In both cases the result is identical to :sql:`SELECT (*) FROM restaurant`.
153+
154+
.. note::
155+
156+
If a column in the table has the same name as the table itself, the column takes priority and its value is returned instead of the row struct.
157+
158+
Structs can be nested further by wrapping :sql:`(*)` in another level of parentheses:
159+
160+
.. code-block:: sql
161+
162+
SELECT ((*)) FROM restaurant;
163+
164+
This returns a single column whose value is a :sql:`STRUCT` containing one field, which is itself the row :sql:`STRUCT`.
165+
116166
Projecting column inside nested a nested :sql:`STRUCT`
117167
------------------------------------------------------
118168

0 commit comments

Comments
 (0)