@eltjs/elt-postgresql 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/postgres-views.d.ts +1 -0
- package/dist/postgres-views.js +8 -0
- package/dist/view.js +4 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -234,6 +234,7 @@ Give the view to the pipeline in `derived`. The view is `marts.unread_count`: it
|
|
|
234
234
|
- The view appears when its query compiles. Thus a reader never finds a view that fails.
|
|
235
235
|
- While the SQL reads a raw table or a reader view that a copy of the pipeline has not made yet, the view waits. It appears at the refresh after that copy loads. Postgres tells which relation is missing (`42P01`), and the view waits only when the pipeline makes that relation.
|
|
236
236
|
- While the SQL reads a view or a computed dataset that comes before it in `derived` and that still waits, the view waits too, as dbt skips a model whose upstream model was skipped.
|
|
237
|
+
- While a view waits, its schema has no view of its name: the refresh drops the view that an earlier declaration made with `DROP VIEW IF EXISTS ... CASCADE`, as dbt's `postgres__drop_view` does. Each view over it goes too: a view of the pipeline waits or is made again by its own refresh, and a view that someone made over it must be made again.
|
|
237
238
|
- Any other error of the query, for example a misspelled table, is a dataset failure. It fails the run with the error of Postgres.
|
|
238
239
|
- The columns must be the same as the columns that the query gives. `marts.catalog` lists them with their descriptions when the view is in `marts`.
|
|
239
240
|
- A refresh that changes nothing leaves the view as it was. The refresh makes the query in a savepoint and compares its definition with the stored one, so the view keeps its OID, its grants and its readers.
|
package/dist/postgres-views.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export declare function publishPostgresViews(sql: postgres.TransactionSql, { sch
|
|
|
8
8
|
schema: string;
|
|
9
9
|
views: readonly PostgresView[];
|
|
10
10
|
}): Promise<void>;
|
|
11
|
+
export declare function withdrawPostgresView(sql: postgres.TransactionSql, schema: string, name: string): Promise<void>;
|
package/dist/postgres-views.js
CHANGED
|
@@ -117,3 +117,11 @@ async function describe(sql, schema, view) {
|
|
|
117
117
|
for (const { statement } of comments)
|
|
118
118
|
await sql.unsafe(statement);
|
|
119
119
|
}
|
|
120
|
+
// Removes a view, its comments and each view over it, in the schema's lock,
|
|
121
|
+
// as dbt drops a model's relation (`drop view if exists ... cascade`): a view
|
|
122
|
+
// of the pipeline over it waits or is made again by its own refresh, and a
|
|
123
|
+
// view that someone made over it is gone.
|
|
124
|
+
export async function withdrawPostgresView(sql, schema, name) {
|
|
125
|
+
await lockSchema(sql, schema);
|
|
126
|
+
await sql.unsafe(`DROP VIEW IF EXISTS ${quote(schema)}.${quote(name)} CASCADE`);
|
|
127
|
+
}
|
package/dist/view.js
CHANGED
|
@@ -3,7 +3,7 @@ import { DerivedDataset, refreshView, } from '@eltjs/elt';
|
|
|
3
3
|
import { PostgresDerivedStatus } from './postgres-derived-status.js';
|
|
4
4
|
import { PostgresDestination } from './postgres-destination.js';
|
|
5
5
|
import { PostgresSession } from './postgres-session.js';
|
|
6
|
-
import { checkView, publishPostgresViews, } from './postgres-views.js';
|
|
6
|
+
import { checkView, publishPostgresViews, withdrawPostgresView, } from './postgres-views.js';
|
|
7
7
|
// A view over what the pipeline loads into one Postgres database: derived
|
|
8
8
|
// data that Postgres computes on each read, as a dbt model materialized as a
|
|
9
9
|
// view is. It lives in the schema of into, where its SQL's bare names resolve
|
|
@@ -44,6 +44,9 @@ export class View extends DerivedDataset {
|
|
|
44
44
|
...made(connections, this.into),
|
|
45
45
|
...earlier.flatMap((dataset) => derivedRelation(dataset) ?? []),
|
|
46
46
|
]),
|
|
47
|
+
withdraw: async () => {
|
|
48
|
+
await session.sql.begin((transaction) => withdrawPostgresView(transaction, this.into.schema, this.name));
|
|
49
|
+
},
|
|
47
50
|
status: new PostgresDerivedStatus(session.sql, this.qualifiedName, 'view', clock),
|
|
48
51
|
});
|
|
49
52
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eltjs/elt-postgresql",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "The Postgres destination of elt: each stream is a typed table in one schema, with a reader view in another, a history of each row for readings as of a position, and the views and computed datasets that a pipeline derives.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@eltjs/elt": "^0.4.
|
|
40
|
+
"@eltjs/elt": "^0.4.3",
|
|
41
41
|
"@zukhruf/async": "^0.8.31",
|
|
42
42
|
"postgres": "^3.4.9"
|
|
43
43
|
},
|