@narrative.io/data-collaboration-sdk-ts 2.21.0 → 2.23.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/build/nql/AstParser.d.ts +19 -2
- package/build/nql/NqlBuilder.d.ts +2 -1
- package/build/nql/NqlBuilder.js +59 -1
- package/package.json +2 -2
package/build/nql/AstParser.d.ts
CHANGED
|
@@ -5,7 +5,24 @@ export interface CreateMaterializedView {
|
|
|
5
5
|
type: "create_materialized_view";
|
|
6
6
|
name: string;
|
|
7
7
|
select: Select;
|
|
8
|
-
|
|
8
|
+
metadata?: CreateMaterializedViewMetadata;
|
|
9
|
+
}
|
|
10
|
+
export interface CreateMaterializedViewMetadata {
|
|
11
|
+
displayName?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
tags?: string[];
|
|
14
|
+
refreshSchedule?: string;
|
|
15
|
+
expire?: string;
|
|
16
|
+
writeMode?: QueryWriteMode;
|
|
17
|
+
extendedStats?: QueryExtendedStats;
|
|
18
|
+
partitionedBy?: QueryPartitionedByEntry[];
|
|
19
|
+
}
|
|
20
|
+
export type QueryWriteMode = "append" | "overwrite";
|
|
21
|
+
export type QueryExtendedStats = "all" | "none";
|
|
22
|
+
export type QueryPartitionedByEntry = {
|
|
23
|
+
field: string;
|
|
24
|
+
transform: string;
|
|
25
|
+
};
|
|
9
26
|
export interface Explain {
|
|
10
27
|
type: "explain";
|
|
11
28
|
query: Select;
|
|
@@ -157,7 +174,7 @@ export interface Like {
|
|
|
157
174
|
value: Expression;
|
|
158
175
|
pattern: string;
|
|
159
176
|
}
|
|
160
|
-
export type Node = (Select | Expression | Deduplication | Table | BooleanExpression | Join | AttributeRef | DatasetColumnRef | RawRef | Lit | And | Or | Not | Between | Equals | NotEquals | Lt | Lte | Gt | Gte | In | IsNull | Like | Raw
|
|
177
|
+
export type Node = (Select | Expression | Deduplication | Table | BooleanExpression | Join | AttributeRef | DatasetColumnRef | RawRef | Lit | And | Or | Not | Between | Equals | NotEquals | Lt | Lte | Gt | Gte | In | IsNull | Like | Raw) & {
|
|
161
178
|
ast_metadata?: AstNodeMetadata;
|
|
162
179
|
};
|
|
163
180
|
export declare function parseStatement(n: ast.NqlAst): Statement | Raw;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { NqlBudget } from "./Ast";
|
|
2
|
-
import type { CreateMaterializedView, Deduplication, Explain, Expression, Output, Raw, Select, Statement, Table } from "./AstParser";
|
|
2
|
+
import type { CreateMaterializedView, CreateMaterializedViewMetadata, Deduplication, Explain, Expression, Output, Raw, Select, Statement, Table } from "./AstParser";
|
|
3
3
|
export type CompiledNql = string;
|
|
4
4
|
export declare function compileStatement(n: Statement): CompiledNql;
|
|
5
5
|
export declare function compileCreateMaterializedView(n: CreateMaterializedView): CompiledNql;
|
|
6
|
+
export declare function compileCreateMaterializedViewMetadata(metadata?: CreateMaterializedViewMetadata): string;
|
|
6
7
|
export declare function compileExplain(n: Explain): CompiledNql;
|
|
7
8
|
export declare function compileSelect(q: Select): CompiledNql;
|
|
8
9
|
export declare function compileBudget(budget: NqlBudget): CompiledNql;
|
package/build/nql/NqlBuilder.js
CHANGED
|
@@ -10,7 +10,65 @@ export function compileStatement(n) {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
export function compileCreateMaterializedView(n) {
|
|
13
|
-
return `CREATE MATERIALIZE VIEW ${quote(n.name)} (${compileSelect(n.select)})`;
|
|
13
|
+
return `CREATE MATERIALIZE VIEW ${quote(n.name)}${compileCreateMaterializedViewMetadata(n.metadata)} AS (${compileSelect(n.select)})`;
|
|
14
|
+
}
|
|
15
|
+
export function compileCreateMaterializedViewMetadata(metadata) {
|
|
16
|
+
function compileDisplayName() {
|
|
17
|
+
if (metadata?.displayName) {
|
|
18
|
+
return `DISPLAY NAME = '${metadata.displayName}' `;
|
|
19
|
+
}
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
function compileDescription() {
|
|
23
|
+
if (metadata?.description) {
|
|
24
|
+
return `DESCRIPTION = '${metadata.description}' `;
|
|
25
|
+
}
|
|
26
|
+
return "";
|
|
27
|
+
}
|
|
28
|
+
function compileTags() {
|
|
29
|
+
if (metadata?.tags && metadata.tags.length > 0) {
|
|
30
|
+
const formattedTags = metadata.tags.map((tag) => `'${tag}'`).join(", ");
|
|
31
|
+
return `TAGS = ( ${formattedTags} ) `;
|
|
32
|
+
}
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
function compileRefreshSchedule() {
|
|
36
|
+
if (metadata?.refreshSchedule) {
|
|
37
|
+
return `REFRESH_SCHEDULE = '${metadata.refreshSchedule}' `;
|
|
38
|
+
}
|
|
39
|
+
return "";
|
|
40
|
+
}
|
|
41
|
+
function compileExpire() {
|
|
42
|
+
if (metadata?.expire) {
|
|
43
|
+
return `EXPIRE = '${metadata.expire}' `;
|
|
44
|
+
}
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
function compileWriteMode() {
|
|
48
|
+
if (metadata?.writeMode) {
|
|
49
|
+
return `WRITE_MODE = '${metadata.writeMode}' `;
|
|
50
|
+
}
|
|
51
|
+
return "";
|
|
52
|
+
}
|
|
53
|
+
function compilePartitionBy() {
|
|
54
|
+
if (metadata?.partitionedBy && metadata.partitionedBy.length > 0) {
|
|
55
|
+
const formattedPartitions = metadata.partitionedBy
|
|
56
|
+
.map((entry) => `${entry.field} ${entry.transform}`)
|
|
57
|
+
.join(", ");
|
|
58
|
+
return `PARTITIONED_BY ${formattedPartitions} `;
|
|
59
|
+
}
|
|
60
|
+
return "";
|
|
61
|
+
}
|
|
62
|
+
function compileExtendedStats() {
|
|
63
|
+
if (metadata?.extendedStats) {
|
|
64
|
+
return `EXTENDED_STATS = '${metadata.extendedStats}' `;
|
|
65
|
+
}
|
|
66
|
+
return "";
|
|
67
|
+
}
|
|
68
|
+
if (!metadata) {
|
|
69
|
+
return "";
|
|
70
|
+
}
|
|
71
|
+
return ` ${compileDisplayName()}${compileDescription()}${compileTags()}${compileRefreshSchedule()}${compileExpire()}${compileWriteMode()}${compileExtendedStats()}${compilePartitionBy()}`;
|
|
14
72
|
}
|
|
15
73
|
export function compileExplain(n) {
|
|
16
74
|
return `EXPLAIN ${compileSelect(n.query)}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narrative.io/data-collaboration-sdk-ts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.23.0",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"repository": "github:narrative-io/data-collaboration-sdk-ts",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"mande": "2.0.9",
|
|
37
37
|
"zod": "3.23.8",
|
|
38
|
-
"bignumber.js": "
|
|
38
|
+
"bignumber.js": "9.1.2"
|
|
39
39
|
},
|
|
40
40
|
"overrides": {
|
|
41
41
|
"semver@<7.5.2": "7.5.2"
|