You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
- Support for **limited** composition of indirects, including `view`, `materialized view`, subqueries and user space tables.
- Uplift compound query string splitting from naive prior state to instead use existing parser function `SplitStatementToPieces()`.
- View documentation updated in `docs/views.md`.
- Added robot test `View Depth Limitation Error Message Shows Correct Max`.
- Added robot test `View JOIN View Returns Results`.
- Added robot test `View JOIN Provider Table Returns Results`.
- Added robot test `Subquery JOIN Subquery Returns Results`.
- Added robot test `CTE Within View Returns Results`.
- Added robot test `Shell Session Multiple Statements Inline`.
- Added robot test `Shell Session Multi Line Then Multi Statement`.
- Added robot test `View JOIN Materialized View Returns Results`.
- Added robot test `View JOIN Subquery Returns Results`.
Copy file name to clipboardExpand all lines: .vscode/launch.json
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -198,6 +198,7 @@
198
198
"select lhs.proj, lhs.bucket from (select 'testing-project' as proj, 'silly-bucket' as bucket) lhs LEFT OUTER join (select name from google.storage.buckets where project = 'testing-project') rhs on lhs.bucket = rhs.name where rhs.name;",
199
199
"insert into google.storage.buckets( project, data__name) select lhs.proj, lhs.bucket from (select 'testing-project' as proj, 'silly-bucket' as bucket) lhs LEFT OUTER join (select name from google.storage.buckets where project = 'testing-project') rhs on lhs.bucket = rhs.name where rhs.name is null returning *;",
200
200
"select description, price_monthly, price_hourly from digitalocean.sizes.sizes where price_monthly = 7.0 order by description desc;",
201
+
"create or replace view vw_repos_name as select name from stackql_repositories; create or replace view vw_repos_url as select name, url from stackql_repositories; select v1.name from vw_repos_name v1 inner join vw_repos_url v2 on v1.name = v2.name;",
-`gonum` DAG adaptations with data flow dependencies representing edges.
10
+
11
+
Some other aspects of data flow analysis:
12
+
13
+
- Relational algebra is implemented in a coupled RDBMS (embedded `sqlite` or `postgres` over TCP). There is a query rewriting process to stringify "containers" for this.
14
+
- There are `transaction control counter` objects and corresponding RDBMS columns to bound relational algebra "containers" and future proof for gargage collection. Some mutex protection is in place.
15
+
- Views in `stackql` permit clobbering of where clause arguments from outside the view. The canonical case is a document-based view in a provider document. A good example are in [test/registry/src/aws/v0.1.0/services/pseudo_s3.yaml](/test/registry/src/aws/v0.1.0/services/pseudo_s3.yaml)at `...s3_bucket_list_and_detail.config.views.select`; one can overwrite `region` here.
16
+
- Views, subqueries, materialized views and user space tables are modelled as "indirections".
17
+
18
+
19
+
## Open Issues
20
+
21
+
## Indirection Data Flow Analysis and Query Execution
22
+
23
+
Data flow analysis for indirections is not composable:
24
+
25
+
- It it impossible to join heterogenous collections of these with each other or conventional resources. There is no recusrsive and stable data flow analysis.
26
+
- While `stackql` does have a `max depth` parameter, I do not believe it is stable enfoced eagerly. Ie: queries too complex should fail at analysis time. Cannot remember param name of=r default.
27
+
28
+
The expected fix for this issue:
29
+
30
+
- Joins, unions etc on indirections work to arbitrary and configurable depth. For depth violations, failure is eager in the analysis phase and error message is plain and in the canonical err stream already widely used.
31
+
- Data flow analysis includes assurance on reuired poarams and viability of projections, joins, etc.
32
+
- Support for CTEs internal to these indirections is in place.
33
+
- Mocked robot tests are added to the canonical test suite, covering off this function.
Copy file name to clipboardExpand all lines: docs/views.md
+50-4Lines changed: 50 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
# Views
4
4
5
-
## *a priori*
5
+
## *a priori*
6
6
7
7
At definition time, it is apparent:
8
8
@@ -24,22 +24,68 @@ The runtime representation of views must support:
24
24
- StackQL views DDL stored in some special stackql table designated for this purpose.
25
25
- Physical table name such as `__iql__.views`.
26
26
- Views need not exist until the `SELECT ... FROM <view>` portion of the query is executed.
27
-
This is advantagesous on RDBMS systems where view creation will fail if physical tables do not exist.
27
+
This is advantageous on RDBMS systems where view creation will fail if physical tables do not exist.
28
28
- We may need a layer of indirection for views to execute, wrt table names containing generation ID.
29
29
Simplest option is input table name.
30
30
- SQL view definitions (translated to physical tables) are stored in the RDBMS.
31
31
- This implies that even quite early in analysis, it must be known that a view is being referenced.
32
32
- Some part of the namespace must be reserved for these views; configurable using existing regex / template namespacing?
33
33
- Quite possibly some specialised object(s) or extension of the `table` interface stages are used for view analysis and parameter routing.
34
34
- Once analysis is complete:
35
-
-Acquistion occurs as normal through primitive DAG.
35
+
-Acquisition occurs as normal through primitive DAG.
36
36
- Selection phase uses physical views.
37
37
38
+
## Materialized views
39
+
40
+
Materialized views are similar in nature to views, although eager executed and lacking in mutation of internal `WHERE` clauses from outside.
41
+
42
+
## User space tables
43
+
44
+
These map to RDBMS tables. The DDL is somewhat impaired; we imagine these are useful for staging in general and applications across: ELT, IAC.
45
+
38
46
39
47
## Subqueries
40
48
41
-
Some aspects of subquery analysis and execution will be similar to views, but not all. What are the considerations for view implementation in the short term such that subsequent subquery implmentation is expedited and natural.
49
+
Some aspects of subquery analysis and execution will be similar to views, but not all. What are the considerations for view implementation in the short term such that subsequent subquery implementation is expedited and natural.
42
50
43
51
To be continued...
44
52
45
53
54
+
## Joins and aliasing on Views etc
55
+
56
+
### Views (lazy evaluated)
57
+
58
+
Views are rendered as inline subqueries `( SELECT ... ) AS "alias"` in the final SQL. When a user alias is provided (e.g. `FROM my_view v1`), the alias `v1` replaces the view name in the `AS` clause.
59
+
60
+
**Supported:**
61
+
- View aliased and selected from: `SELECT * FROM my_view v1`.
62
+
- View JOIN view: `SELECT ... FROM v1 INNER JOIN v2 ON ...`.
63
+
- View JOIN provider table: `SELECT ... FROM my_view v1 INNER JOIN provider.svc.resource r ON ...`.
64
+
- View JOIN subquery: `SELECT ... FROM my_view v1 INNER JOIN (SELECT ...) sq ON ...`.
65
+
- View JOIN materialized view: `SELECT ... FROM my_view v1 INNER JOIN mv ON ...`.
66
+
- Nested views (view wrapping a view): supported up to configurable depth (`--indirect-depth-max`, default 5).
67
+
- WHERE clause parameter clobbering from outside the view, using **unqualified** parameters (e.g. `WHERE region = 'us-east-1'`).
68
+
69
+
**Not supported:**
70
+
- Table-qualified parameter clobbering into views (e.g. `WHERE v1.region = 'us-east-1'` will not override the view's internal `region` parameter).
71
+
- Joins of three or more heterogeneous indirections (e.g. `view JOIN subquery JOIN provider_table`). Binary joins work; three-way and beyond fail with parameter count mismatches in the SQL composition layer.
72
+
73
+
### Materialized views (eager evaluated)
74
+
75
+
Materialized views are persisted as physical tables in the RDBMS. They are referenced by their table name directly (not as inline subqueries).
76
+
77
+
**Supported:**
78
+
- Materialized view aliased and selected from.
79
+
- Materialized view joined with provider tables, user space tables, views and subqueries.
80
+
-`CREATE`, `DROP`, `REFRESH`, `CREATE OR REPLACE` lifecycle.
81
+
82
+
**Not supported:**
83
+
- WHERE clause parameter clobbering from outside (materialized views are snapshot-based).
84
+
85
+
### Subqueries
86
+
87
+
Subqueries appear as inline `( SELECT ... )` expressions. CTEs (`WITH ... AS`) are converted to subqueries at AST level and handled identically.
88
+
89
+
### User space tables
90
+
91
+
User space tables are RDBMS-resident tables created via `CREATE TABLE`. They can participate in joins with any other indirection type.
0 commit comments