@gscdump/engine 0.9.2 → 0.10.0
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 -1
- package/dist/_chunks/dispatch.mjs +11 -17
- package/dist/_chunks/engine.mjs +622 -0
- package/dist/_chunks/pg-adapter.mjs +1 -10
- package/dist/_chunks/registry.d.mts +137 -15
- package/dist/_chunks/resolver.mjs +2 -25
- package/dist/_chunks/snapshot.d.mts +14 -0
- package/dist/_chunks/storage.d.mts +1 -20
- package/dist/adapters/node.d.mts +91 -0
- package/dist/adapters/node.mjs +133 -0
- package/dist/analyzer/index.d.mts +4 -50
- package/dist/analyzer/index.mjs +17 -8
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +6 -621
- package/dist/planner.d.mts +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/resolver/index.d.mts +1 -23
- package/dist/resolver/index.mjs +3 -3
- package/dist/rollups.d.mts +163 -0
- package/dist/rollups.mjs +346 -0
- package/dist/snapshot.d.mts +1 -13
- package/dist/source/index.d.mts +30 -8
- package/dist/source/index.mjs +42 -7
- package/package.json +10 -5
- package/dist/_chunks/source-types.d.mts +0 -31
- /package/dist/_chunks/{planner.mjs → compiler.mjs} +0 -0
package/dist/source/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { h as resolveToSQL, n as pgResolverAdapter, s as assertDimensionsSupported } from "../_chunks/pg-adapter.mjs";
|
|
2
|
+
import { i as getFilterDimensions } from "../_chunks/resolver.mjs";
|
|
3
3
|
import { n as runAnalyzerFromSource } from "../_chunks/dispatch.mjs";
|
|
4
4
|
var AttachedTableMissingError = class extends Error {
|
|
5
5
|
constructor(missing) {
|
|
@@ -11,7 +11,12 @@ var AttachedTableMissingError = class extends Error {
|
|
|
11
11
|
const ATTACHED_TABLE_CAPABILITIES = {
|
|
12
12
|
fileSets: true,
|
|
13
13
|
attachedTables: true,
|
|
14
|
-
regex: true
|
|
14
|
+
regex: true,
|
|
15
|
+
executeSql: true
|
|
16
|
+
};
|
|
17
|
+
const ATTACHED_TABLE_CAPABILITIES_WITH_ADAPTER = {
|
|
18
|
+
...ATTACHED_TABLE_CAPABILITIES,
|
|
19
|
+
adapter: true
|
|
15
20
|
};
|
|
16
21
|
function rewriteForTableSource(sql, schema, fileSets) {
|
|
17
22
|
let out = sql;
|
|
@@ -22,11 +27,13 @@ function rewriteForTableSource(sql, schema, fileSets) {
|
|
|
22
27
|
return out;
|
|
23
28
|
}
|
|
24
29
|
function createAttachedTableSource(runner, options) {
|
|
25
|
-
const { schema, signal, attachedTables } = options;
|
|
30
|
+
const { schema, signal, attachedTables, adapter } = options;
|
|
26
31
|
const attachedSet = attachedTables ? new Set(attachedTables) : null;
|
|
27
32
|
return {
|
|
28
33
|
name: "attached-table",
|
|
29
|
-
|
|
34
|
+
kind: "browser",
|
|
35
|
+
capabilities: adapter ? ATTACHED_TABLE_CAPABILITIES_WITH_ADAPTER : ATTACHED_TABLE_CAPABILITIES,
|
|
36
|
+
adapter,
|
|
30
37
|
async queryRows() {
|
|
31
38
|
throw new Error("attached-table source: queryRows is not supported; use SQL analyzers");
|
|
32
39
|
},
|
|
@@ -43,6 +50,31 @@ function createAttachedTableSource(runner, options) {
|
|
|
43
50
|
}
|
|
44
51
|
};
|
|
45
52
|
}
|
|
53
|
+
function createSqlQuerySource(options) {
|
|
54
|
+
const { name, kind, adapter, execute, siteId, extraCapabilities } = options;
|
|
55
|
+
return {
|
|
56
|
+
name,
|
|
57
|
+
kind,
|
|
58
|
+
capabilities: {
|
|
59
|
+
...adapter.capabilities,
|
|
60
|
+
...extraCapabilities,
|
|
61
|
+
executeSql: true,
|
|
62
|
+
adapter: true
|
|
63
|
+
},
|
|
64
|
+
adapter,
|
|
65
|
+
siteId,
|
|
66
|
+
async queryRows(state) {
|
|
67
|
+
const resolved = resolveToSQL(state, {
|
|
68
|
+
adapter,
|
|
69
|
+
siteId
|
|
70
|
+
});
|
|
71
|
+
return execute(resolved.sql, resolved.params);
|
|
72
|
+
},
|
|
73
|
+
executeSql(sql, params) {
|
|
74
|
+
return execute(sql, params ?? []);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
46
78
|
function isMetricDimension(dim) {
|
|
47
79
|
return [
|
|
48
80
|
"clicks",
|
|
@@ -60,13 +92,16 @@ const ENGINE_QUERY_CAPABILITIES = {
|
|
|
60
92
|
const ENGINE_SOURCE_CAPABILITIES = {
|
|
61
93
|
...ENGINE_QUERY_CAPABILITIES,
|
|
62
94
|
fileSets: true,
|
|
63
|
-
|
|
95
|
+
executeSql: true,
|
|
96
|
+
adapter: true
|
|
64
97
|
};
|
|
65
98
|
function createEngineQuerySource(options) {
|
|
66
99
|
const { engine, ctx } = options;
|
|
67
100
|
return {
|
|
68
101
|
name: "engine",
|
|
102
|
+
kind: "local",
|
|
69
103
|
capabilities: ENGINE_SOURCE_CAPABILITIES,
|
|
104
|
+
adapter: pgResolverAdapter,
|
|
70
105
|
async queryRows(state) {
|
|
71
106
|
const filterDims = getFilterDimensions(state.filter, isMetricDimension);
|
|
72
107
|
assertDimensionsSupported([...state.dimensions, ...filterDims], "stored", "engine query source");
|
|
@@ -110,4 +145,4 @@ async function queryComparisonRows(source, current, previous) {
|
|
|
110
145
|
previous: previousRows
|
|
111
146
|
};
|
|
112
147
|
}
|
|
113
|
-
export { AttachedTableMissingError, ENGINE_QUERY_CAPABILITIES, createAttachedTableSource, createEngineQuerySource, queryComparisonRows, queryRows, rewriteForTableSource, runAnalyzerWithEngine, typedQuery };
|
|
148
|
+
export { AttachedTableMissingError, ENGINE_QUERY_CAPABILITIES, createAttachedTableSource, createEngineQuerySource, createSqlQuerySource, queryComparisonRows, queryRows, rewriteForTableSource, runAnalyzerWithEngine, typedQuery };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/engine",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.10.0",
|
|
5
5
|
"description": "Append-only Parquet/DuckDB storage engine + planner + adapters for the gscdump pipeline. Node + edge runtimes; opt-in heavy peers.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -66,10 +66,15 @@
|
|
|
66
66
|
"import": "./dist/entities.mjs",
|
|
67
67
|
"default": "./dist/entities.mjs"
|
|
68
68
|
},
|
|
69
|
+
"./rollups": {
|
|
70
|
+
"types": "./dist/rollups.d.mts",
|
|
71
|
+
"import": "./dist/rollups.mjs",
|
|
72
|
+
"default": "./dist/rollups.mjs"
|
|
73
|
+
},
|
|
69
74
|
"./node": {
|
|
70
|
-
"types": "./dist/adapters/
|
|
71
|
-
"import": "./dist/adapters/
|
|
72
|
-
"default": "./dist/adapters/
|
|
75
|
+
"types": "./dist/adapters/node.d.mts",
|
|
76
|
+
"import": "./dist/adapters/node.mjs",
|
|
77
|
+
"default": "./dist/adapters/node.mjs"
|
|
73
78
|
},
|
|
74
79
|
"./filesystem": {
|
|
75
80
|
"types": "./dist/adapters/filesystem.d.mts",
|
|
@@ -159,7 +164,7 @@
|
|
|
159
164
|
"dependencies": {
|
|
160
165
|
"drizzle-orm": "^0.45.2",
|
|
161
166
|
"proper-lockfile": "^4.1.2",
|
|
162
|
-
"gscdump": "0.
|
|
167
|
+
"gscdump": "0.10.0"
|
|
163
168
|
},
|
|
164
169
|
"devDependencies": {
|
|
165
170
|
"@duckdb/duckdb-wasm": "^1.32.0",
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { PlannerCapabilities } from "gscdump/query/plan";
|
|
2
|
-
import { TableName } from "gscdump/contracts";
|
|
3
|
-
import { BuilderState } from "gscdump/query";
|
|
4
|
-
type QueryRow = Record<string, unknown>;
|
|
5
|
-
interface FileSet {
|
|
6
|
-
table: TableName;
|
|
7
|
-
partitions: string[];
|
|
8
|
-
}
|
|
9
|
-
interface ExecuteSqlOptions {
|
|
10
|
-
fileSets?: Record<string, FileSet>;
|
|
11
|
-
}
|
|
12
|
-
interface SourceCapabilities extends PlannerCapabilities {
|
|
13
|
-
attachedTables?: boolean;
|
|
14
|
-
fileSets?: boolean;
|
|
15
|
-
localSource?: boolean;
|
|
16
|
-
}
|
|
17
|
-
interface RowQuerySource {
|
|
18
|
-
name?: string;
|
|
19
|
-
capabilities: SourceCapabilities;
|
|
20
|
-
queryRows: (state: BuilderState) => Promise<QueryRow[]>;
|
|
21
|
-
readonly executeSql?: undefined;
|
|
22
|
-
}
|
|
23
|
-
interface SqlQuerySource {
|
|
24
|
-
name?: string;
|
|
25
|
-
capabilities: SourceCapabilities;
|
|
26
|
-
queryRows: (state: BuilderState) => Promise<QueryRow[]>;
|
|
27
|
-
executeSql: (sql: string, params?: unknown[], opts?: ExecuteSqlOptions) => Promise<QueryRow[]>;
|
|
28
|
-
}
|
|
29
|
-
type AnalysisQuerySource = RowQuerySource | SqlQuerySource;
|
|
30
|
-
declare function isSqlQuerySource(s: AnalysisQuerySource): s is SqlQuerySource;
|
|
31
|
-
export { RowQuerySource as a, isSqlQuerySource as c, QueryRow as i, ExecuteSqlOptions as n, SourceCapabilities as o, FileSet as r, SqlQuerySource as s, AnalysisQuerySource as t };
|
|
File without changes
|