@narrative.io/data-collaboration-sdk-ts 0.27.0 → 1.0.1
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/access-rules/index.d.ts +1 -1
- package/build/access-rules/types.d.ts +1 -1
- package/build/access-tokens/index.d.ts +2 -2
- package/build/apps/index.d.ts +2 -2
- package/build/attributes/index.d.ts +2 -2
- package/build/authentication/index.d.ts +1 -1
- package/build/base-api.d.ts +3 -3
- package/build/company-info/index.d.ts +2 -2
- package/build/connections/index.d.ts +1 -1
- package/build/contracts/index.d.ts +1 -1
- package/build/data-planes/index.d.ts +1 -1
- package/build/data-streams/index.d.ts +2 -2
- package/build/data-streams/index.js +1 -3
- package/build/data-streams/types.d.ts +1 -1
- package/build/datasets/index.d.ts +15 -15
- package/build/datasets/index.js +12 -12
- package/build/datasets/types.d.ts +1 -1
- package/build/forecast/index.d.ts +1 -1
- package/build/forecast/types.d.ts +1 -1
- package/build/health/index.d.ts +1 -1
- package/build/index.d.ts +35 -35
- package/build/index.js +25 -23
- package/build/installations/index.d.ts +2 -2
- package/build/jobs/index.d.ts +2 -2
- package/build/jobs/types.d.ts +3 -3
- package/build/mappings/index.d.ts +2 -2
- package/build/mappings/index.js +3 -3
- package/build/nql/AstParser.js +10 -15
- package/build/nql/AstTraverse.d.ts +1 -1
- package/build/nql/AstTraverse.js +4 -4
- package/build/nql/DataRulesConverter.d.ts +2 -2
- package/build/nql/DataRulesConverter.js +20 -23
- package/build/nql/NQLParser.js +23 -31
- package/build/nql/NqlBuilder.d.ts +2 -2
- package/build/nql/NqlBuilder.js +8 -21
- package/build/nql/SubstraitParser.d.ts +1 -2
- package/build/nql/SubstraitParser.js +27 -39
- package/build/nql/index.d.ts +2 -2
- package/build/nql/types.d.ts +1 -1
- package/build/ping/index.d.ts +1 -1
- package/build/products/index.d.ts +1 -1
- package/build/resources/index.d.ts +3 -3
- package/build/rosetta-stone/index.d.ts +1 -1
- package/build/subscriptions/index.d.ts +2 -2
- package/build/subscriptions/types.d.ts +2 -2
- package/build/uploads/index.d.ts +1 -1
- package/build/uploads/index.js +1 -3
- package/build/utils.js +7 -11
- package/build/whoami/index.d.ts +1 -1
- package/package.json +43 -45
|
@@ -35,7 +35,7 @@ async function getAttributesFromFields(fields) {
|
|
|
35
35
|
const uniqueAttributes = [
|
|
36
36
|
...new Set(fields.map((field) => stripQuotes(field.field).split(".")[0])),
|
|
37
37
|
].filter((att) => !att.startsWith("_"));
|
|
38
|
-
|
|
38
|
+
for (const att of uniqueAttributes) {
|
|
39
39
|
const isObjectProperty = isObject(attributes.records, att);
|
|
40
40
|
const relevantFields = isObjectProperty != null
|
|
41
41
|
? fields.filter((field) => stripQuotes(field.field).split(".")[0] === att &&
|
|
@@ -50,9 +50,9 @@ async function getAttributesFromFields(fields) {
|
|
|
50
50
|
fields: relevantFields.length > 0
|
|
51
51
|
? relevantFields
|
|
52
52
|
: buildField(att, findAttributeProperties(attributes.records, att)),
|
|
53
|
-
optional: fields.some((field) => field.field.startsWith(att
|
|
53
|
+
optional: fields.some((field) => field.field.startsWith(`${att}.`) && field.filter === undefined),
|
|
54
54
|
});
|
|
55
|
-
}
|
|
55
|
+
}
|
|
56
56
|
ensureAtLeastOneRequired(attributesArray);
|
|
57
57
|
return attributesArray;
|
|
58
58
|
}
|
|
@@ -102,14 +102,12 @@ function getPriceFromNql(nqlObject) {
|
|
|
102
102
|
micro_cents_usd: priceFilter[0].right * 100000000,
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
if (typeof priceFilter[0].left === "number") {
|
|
106
106
|
return {
|
|
107
107
|
micro_cents_usd: priceFilter[0].left * 100000000,
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
throw new Error("Expected one side of price filter to be a number");
|
|
112
|
-
}
|
|
110
|
+
throw new Error("Expected one side of price filter to be a number");
|
|
113
111
|
}
|
|
114
112
|
/**
|
|
115
113
|
* Extract fields from an NQL object.
|
|
@@ -119,16 +117,16 @@ function getPriceFromNql(nqlObject) {
|
|
|
119
117
|
function getFieldsFromNql(nqlObject) {
|
|
120
118
|
const fieldsArray = [];
|
|
121
119
|
// Extract all fields from the 'select' section and mark them as exported.
|
|
122
|
-
nqlObject.select
|
|
120
|
+
for (const field of nqlObject.select) {
|
|
123
121
|
fieldsArray.push({
|
|
124
122
|
field: stripQuotes(field.field),
|
|
125
123
|
exported: true,
|
|
126
124
|
});
|
|
127
|
-
}
|
|
125
|
+
}
|
|
128
126
|
// Process all filter expressions from the 'where' section.
|
|
129
|
-
nqlObject.where.filterExpressions
|
|
127
|
+
for (const expression of nqlObject.where.filterExpressions) {
|
|
130
128
|
handleFilterExpression(expression, fieldsArray);
|
|
131
|
-
}
|
|
129
|
+
}
|
|
132
130
|
return fieldsArray;
|
|
133
131
|
}
|
|
134
132
|
/**
|
|
@@ -158,7 +156,10 @@ function handleFilterExpression(expression, fieldsArray) {
|
|
|
158
156
|
* @param {any} filterExpression - The filter expression to add to the field.
|
|
159
157
|
*/
|
|
160
158
|
function updateFieldsArray(field, fieldsArray, filterExpression) {
|
|
161
|
-
const existingEntry = fieldsArray.find((entry) => entry.field ===
|
|
159
|
+
const existingEntry = fieldsArray.find((entry) => entry.field ===
|
|
160
|
+
stripQuotes(typeof field === "object" && "field" in field
|
|
161
|
+
? field.field
|
|
162
|
+
: field));
|
|
162
163
|
if (existingEntry !== undefined) {
|
|
163
164
|
if (existingEntry.filter !== undefined &&
|
|
164
165
|
typeof existingEntry.filter === "object" &&
|
|
@@ -174,7 +175,9 @@ function updateFieldsArray(field, fieldsArray, filterExpression) {
|
|
|
174
175
|
else {
|
|
175
176
|
// If this field does not exist in the fieldsArray, add it with the new filter expression.
|
|
176
177
|
fieldsArray.push({
|
|
177
|
-
field: stripQuotes(field
|
|
178
|
+
field: stripQuotes(typeof field === "object" && "field" in field
|
|
179
|
+
? field.field
|
|
180
|
+
: field),
|
|
178
181
|
exported: false,
|
|
179
182
|
filter: { expressions: [filterExpression] },
|
|
180
183
|
});
|
|
@@ -205,15 +208,13 @@ function expressionToString(expr) {
|
|
|
205
208
|
if (typeof expr === "string") {
|
|
206
209
|
return `${addParentheses(expr)}`;
|
|
207
210
|
}
|
|
208
|
-
|
|
211
|
+
if (typeof expr === "number") {
|
|
209
212
|
return expr.toString();
|
|
210
213
|
}
|
|
211
|
-
|
|
214
|
+
if (typeof expr === "boolean") {
|
|
212
215
|
return expr.toString();
|
|
213
216
|
}
|
|
214
|
-
|
|
215
|
-
return expr.field;
|
|
216
|
-
}
|
|
217
|
+
return expr.field;
|
|
217
218
|
}
|
|
218
219
|
/**
|
|
219
220
|
* Adds parentheses to 'CURRENT_TIMESTAMP' or 'CURRENT_DATE' in the input string
|
|
@@ -311,7 +312,6 @@ export function generateFromClause(dataRules) {
|
|
|
311
312
|
// Handle Column Sets
|
|
312
313
|
if (dataRules.column_sets !== undefined) {
|
|
313
314
|
for (const columnSet of dataRules.column_sets) {
|
|
314
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
315
315
|
const { dataset_id } = columnSet;
|
|
316
316
|
fromClause.push(`company_data.${dataset_id}`);
|
|
317
317
|
}
|
|
@@ -322,7 +322,6 @@ export function generateFromClause(dataRules) {
|
|
|
322
322
|
}
|
|
323
323
|
// Handle JOINs
|
|
324
324
|
if (dataRules.dataset_filter !== undefined) {
|
|
325
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
326
325
|
const { dataset_id, attribute } = dataRules.dataset_filter;
|
|
327
326
|
const joinClause = `JOIN company_data.${dataset_id} ON company_data.${dataset_id}."${attribute.field}" = narrative.rosetta_stone."${attribute.field}"`;
|
|
328
327
|
fromClause.push(joinClause);
|
|
@@ -354,12 +353,11 @@ export function dataRulesToSQL(dataRules) {
|
|
|
354
353
|
function generateSelectClause(dataRules) {
|
|
355
354
|
let selectColumns = [];
|
|
356
355
|
const quoteField = (field) => field.includes(".")
|
|
357
|
-
? `${field.split(".")[0]}
|
|
356
|
+
? `${field.split(".")[0]}."${field.split(".")[1]}"`
|
|
358
357
|
: `"${field}"`;
|
|
359
358
|
// Handle Column Sets
|
|
360
359
|
if (dataRules.column_sets !== undefined) {
|
|
361
360
|
for (const columnSet of dataRules.column_sets) {
|
|
362
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
363
361
|
const { dataset_id, fields } = columnSet;
|
|
364
362
|
const qualifiedFields = fields
|
|
365
363
|
.filter((f) => f.exported)
|
|
@@ -418,7 +416,6 @@ function generateWhereClause(dataRules) {
|
|
|
418
416
|
// Handle Column Sets
|
|
419
417
|
if (dataRules.column_sets !== undefined) {
|
|
420
418
|
for (const columnSet of dataRules.column_sets) {
|
|
421
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
422
419
|
const { dataset_id, fields } = columnSet;
|
|
423
420
|
for (const field of fields) {
|
|
424
421
|
if (field.filter !== undefined) {
|
package/build/nql/NQLParser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NqlBooleanExpressionObj, NqlBudgetObj, NqlFieldObj, NqlFilterExpressionObj, NqlObj, NqlPreSelectExpressionObj, NqlTableObject, NqlWhereObj,
|
|
1
|
+
import { NqlBooleanExpressionObj, NqlBudgetObj, NqlFieldObj, NqlFilterExpressionObj, NqlFilterUnaryExpressionObj, NqlObj, NqlPreSelectExpressionObj, NqlTableObject, NqlWhereObj, } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Retrieves the WHERE clause from the given NQL (Nested Query Language) string and returns a parsed NqlWhereClause object.
|
|
4
4
|
*
|
|
@@ -17,9 +17,7 @@ export function getWhere(nql) {
|
|
|
17
17
|
filterExpressions,
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
throw new Error("No WHERE clause found");
|
|
22
|
-
}
|
|
20
|
+
throw new Error("No WHERE clause found");
|
|
23
21
|
}
|
|
24
22
|
/**
|
|
25
23
|
* Retrieves the tables from the given NQL (Nested Query Language) string and returns an array of parsed NqlTable objects.
|
|
@@ -41,9 +39,7 @@ export function getFrom(nql) {
|
|
|
41
39
|
});
|
|
42
40
|
return tables;
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
throw new Error("No FROM clause found");
|
|
46
|
-
}
|
|
42
|
+
throw new Error("No FROM clause found");
|
|
47
43
|
}
|
|
48
44
|
/**
|
|
49
45
|
* Extracts boolean expressions from the WHERE clause string and returns an array of parsed NqlBooleanExpression objects.
|
|
@@ -54,9 +50,10 @@ export function getFrom(nql) {
|
|
|
54
50
|
function getBooleanExpressionsFromWhere(where) {
|
|
55
51
|
const booleanRegex = /\s(OR|AND)\s/gi;
|
|
56
52
|
const matches = [];
|
|
57
|
-
let boolMatch;
|
|
58
|
-
while (
|
|
53
|
+
let boolMatch = booleanRegex.exec(where);
|
|
54
|
+
while (boolMatch !== null) {
|
|
59
55
|
matches.push(boolMatch[1].trim().toUpperCase());
|
|
56
|
+
boolMatch = booleanRegex.exec(where);
|
|
60
57
|
}
|
|
61
58
|
return NqlBooleanExpressionObj.array().parse(matches);
|
|
62
59
|
}
|
|
@@ -112,7 +109,7 @@ function parseFieldFromString(fieldStr) {
|
|
|
112
109
|
function parseString(value) {
|
|
113
110
|
// Attempt to parse as a number
|
|
114
111
|
const parsedNumber = Number(value);
|
|
115
|
-
if (!isNaN(parsedNumber)) {
|
|
112
|
+
if (!Number.isNaN(parsedNumber)) {
|
|
116
113
|
return parsedNumber;
|
|
117
114
|
}
|
|
118
115
|
// Attempt to parse as a boolean
|
|
@@ -231,9 +228,7 @@ export function getSelect(nql) {
|
|
|
231
228
|
return NqlFieldObj.parse({ table: t, field: field.join(".") });
|
|
232
229
|
});
|
|
233
230
|
}
|
|
234
|
-
|
|
235
|
-
throw new Error("No selected fields found");
|
|
236
|
-
}
|
|
231
|
+
throw new Error("No selected fields found");
|
|
237
232
|
}
|
|
238
233
|
/**
|
|
239
234
|
* Builds a SELECT clause for an NQL (Natural Query Language) query based on the provided fields.
|
|
@@ -243,11 +238,12 @@ export function getSelect(nql) {
|
|
|
243
238
|
* @throws {Error} - If any of the provided fields are invalid.
|
|
244
239
|
*/
|
|
245
240
|
export function buildSelect(fields) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
241
|
+
for (const f of fields) {
|
|
242
|
+
NqlFieldObj.parse(f);
|
|
243
|
+
}
|
|
244
|
+
return `SELECT ${fields
|
|
245
|
+
.map((f) => `${f.table.database}.${f.table.table}.${f.field}`)
|
|
246
|
+
.join(", ")}`;
|
|
251
247
|
}
|
|
252
248
|
/**
|
|
253
249
|
* Parses a string in NQL format and returns an NqlBudgetType object.
|
|
@@ -263,15 +259,13 @@ export function getLimit(nql) {
|
|
|
263
259
|
if (match != null) {
|
|
264
260
|
const [, value, currency, period] = match;
|
|
265
261
|
const result = {
|
|
266
|
-
value: parseInt(value, 10),
|
|
262
|
+
value: Number.parseInt(value, 10),
|
|
267
263
|
currency: currency.toUpperCase(),
|
|
268
264
|
period: period.toUpperCase(),
|
|
269
265
|
};
|
|
270
266
|
return NqlBudgetObj.parse(result);
|
|
271
267
|
}
|
|
272
|
-
|
|
273
|
-
throw new Error("Invalid budget");
|
|
274
|
-
}
|
|
268
|
+
throw new Error("Invalid budget");
|
|
275
269
|
}
|
|
276
270
|
/**
|
|
277
271
|
* Builds a LIMIT clause for an NQL (Narrative Query Language) query based on the provided budget object.
|
|
@@ -312,7 +306,7 @@ export function buildFrom(from) {
|
|
|
312
306
|
export function buildWhere(where) {
|
|
313
307
|
NqlWhereObj.parse(where);
|
|
314
308
|
let str = where.filterExpressions.length > 0 ? "WHERE" : "";
|
|
315
|
-
where.filterExpressions.
|
|
309
|
+
for (const [i, f] of where.filterExpressions.entries()) {
|
|
316
310
|
if ("field" in f) {
|
|
317
311
|
str += ` ${buildField(f.field)} ${f.operator}`;
|
|
318
312
|
}
|
|
@@ -322,7 +316,7 @@ export function buildWhere(where) {
|
|
|
322
316
|
if (where.booleanExpressions[i] != null) {
|
|
323
317
|
str += ` ${where.booleanExpressions[i]}`;
|
|
324
318
|
}
|
|
325
|
-
}
|
|
319
|
+
}
|
|
326
320
|
return str;
|
|
327
321
|
}
|
|
328
322
|
export function buildField(field) {
|
|
@@ -345,13 +339,11 @@ export function getNqlObject(nql, type) {
|
|
|
345
339
|
if (type === undefined || type === "full") {
|
|
346
340
|
return parsed;
|
|
347
341
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
};
|
|
354
|
-
}
|
|
342
|
+
return {
|
|
343
|
+
where: createSemanticWhere(parsed.where),
|
|
344
|
+
from: parsed.from,
|
|
345
|
+
select: parsed.select,
|
|
346
|
+
};
|
|
355
347
|
}
|
|
356
348
|
export function createSemanticWhere(expressionContainer) {
|
|
357
349
|
const copy = JSON.parse(JSON.stringify(expressionContainer)); // deep copy
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { NqlBudget } from "./Ast";
|
|
2
|
+
import type { CreateMaterializedView, 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;
|
package/build/nql/NqlBuilder.js
CHANGED
|
@@ -10,7 +10,6 @@ export function compileStatement(n) {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
export function compileCreateMaterializedView(n) {
|
|
13
|
-
// eslint-disable-next-line prettier/prettier
|
|
14
13
|
return `CREATE MATERIALIZE VIEW ${quote(n.name)} (${compileSelect(n.select)})`;
|
|
15
14
|
}
|
|
16
15
|
export function compileExplain(n) {
|
|
@@ -41,7 +40,6 @@ export function compileBudget(budget) {
|
|
|
41
40
|
default:
|
|
42
41
|
unreachable(budget.period.type);
|
|
43
42
|
}
|
|
44
|
-
// eslint-disable-next-line prettier/prettier
|
|
45
43
|
return `LIMIT ${budget.amount.value} ${budget.amount.currency.toUpperCase()} ${period}`;
|
|
46
44
|
}
|
|
47
45
|
export function compileDeduplication(d) {
|
|
@@ -49,17 +47,13 @@ export function compileDeduplication(d) {
|
|
|
49
47
|
const expressions = d.expressions.map(compileExpression).join(", ");
|
|
50
48
|
return `ROW_NUMBER() OVER (PARTITION BY ${expressions} ORDER BY 0) = 1`;
|
|
51
49
|
}
|
|
52
|
-
|
|
53
|
-
return raw(d);
|
|
54
|
-
}
|
|
50
|
+
return raw(d);
|
|
55
51
|
}
|
|
56
52
|
export function compileFrom(tables) {
|
|
57
53
|
if (isArray(tables)) {
|
|
58
54
|
return compileTableRefs(tables);
|
|
59
55
|
}
|
|
60
|
-
|
|
61
|
-
return compileRawRef(tables.nql, tables.as);
|
|
62
|
-
}
|
|
56
|
+
return compileRawRef(tables.nql, tables.as);
|
|
63
57
|
}
|
|
64
58
|
function compileTableRefs(tables) {
|
|
65
59
|
function ref(table) {
|
|
@@ -67,7 +61,7 @@ function compileTableRefs(tables) {
|
|
|
67
61
|
case "dataset":
|
|
68
62
|
return aliased(`company_data.${quote(table.datasetId.toString())}`, table.as, false);
|
|
69
63
|
case "rosetta_stone":
|
|
70
|
-
return aliased(
|
|
64
|
+
return aliased("narrative.rosetta_stone", table.as, false);
|
|
71
65
|
case "raw_table":
|
|
72
66
|
return aliased(table.nql, table.as, false);
|
|
73
67
|
}
|
|
@@ -117,7 +111,6 @@ function compileTableRefs(tables) {
|
|
|
117
111
|
if (
|
|
118
112
|
// Prefer explicit `join !== undefined` to the use of the `?` operator so that typescript
|
|
119
113
|
// compile knows that the join is defined in the subsequent lexical scope.
|
|
120
|
-
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
|
|
121
114
|
table.join !== undefined &&
|
|
122
115
|
table.join.condition !== null &&
|
|
123
116
|
table.join.conditionType !== "none") {
|
|
@@ -220,9 +213,7 @@ function compileAttributeRef(column, as, aliasParens) {
|
|
|
220
213
|
if (index === 0) {
|
|
221
214
|
return `${acc}${quote(segment)}`;
|
|
222
215
|
}
|
|
223
|
-
|
|
224
|
-
return `${acc}.${quote(segment)}`;
|
|
225
|
-
}
|
|
216
|
+
return `${acc}.${quote(segment)}`;
|
|
226
217
|
}, "");
|
|
227
218
|
return aliased(`narrative.rosetta_stone.${quotedSegments}`, as, aliasParens);
|
|
228
219
|
}
|
|
@@ -242,9 +233,7 @@ function compileDatasetColumnRef(datasetId, column, as, aliasParen) {
|
|
|
242
233
|
if (index === 0) {
|
|
243
234
|
return `${acc}${quote(segment)}`;
|
|
244
235
|
}
|
|
245
|
-
|
|
246
|
-
return `${acc}.${quote(segment)}`;
|
|
247
|
-
}
|
|
236
|
+
return `${acc}.${quote(segment)}`;
|
|
248
237
|
}, "");
|
|
249
238
|
return aliased(`company_data.${quote(datasetId.toString())}.${formattedColumn}`, as, false);
|
|
250
239
|
}
|
|
@@ -311,10 +300,10 @@ function compileLit(value, valueType, as) {
|
|
|
311
300
|
break;
|
|
312
301
|
}
|
|
313
302
|
case "long":
|
|
314
|
-
valueNql = `${parseInt(value)}`;
|
|
303
|
+
valueNql = `${Number.parseInt(value)}`;
|
|
315
304
|
break;
|
|
316
305
|
case "double":
|
|
317
|
-
valueNql = `${parseFloat(value)}`;
|
|
306
|
+
valueNql = `${Number.parseFloat(value)}`;
|
|
318
307
|
break;
|
|
319
308
|
default:
|
|
320
309
|
// todo(mbabic) don't really know what to do here/how complicated this needs to be
|
|
@@ -343,9 +332,7 @@ function aliased(nql, as, parens) {
|
|
|
343
332
|
if ((parens === undefined || parens) && as !== undefined) {
|
|
344
333
|
return `(${alias})`;
|
|
345
334
|
}
|
|
346
|
-
|
|
347
|
-
return alias;
|
|
348
|
-
}
|
|
335
|
+
return alias;
|
|
349
336
|
}
|
|
350
337
|
function str(s) {
|
|
351
338
|
// todo(mbabic) is this the right escaping for calcite?
|
|
@@ -185,9 +185,7 @@ class SubstraitParser {
|
|
|
185
185
|
if (ref.structField != null) {
|
|
186
186
|
return this.structFieldToField(ref.structField, exprIn);
|
|
187
187
|
}
|
|
188
|
-
|
|
189
|
-
throw new Error(`Unrecognized direct reference: ${JSON.stringify(ref)}`);
|
|
190
|
-
}
|
|
188
|
+
throw new Error(`Unrecognized direct reference: ${JSON.stringify(ref)}`);
|
|
191
189
|
}
|
|
192
190
|
/**
|
|
193
191
|
* Convert a reference to a stringified representation
|
|
@@ -199,9 +197,7 @@ class SubstraitParser {
|
|
|
199
197
|
if (ref.directReference != null) {
|
|
200
198
|
return this.directReferenceToField(ref.directReference, exprIn);
|
|
201
199
|
}
|
|
202
|
-
|
|
203
|
-
throw new Error(`Unrecognized reference: ${JSON.stringify(ref)}`);
|
|
204
|
-
}
|
|
200
|
+
throw new Error(`Unrecognized reference: ${JSON.stringify(ref)}`);
|
|
205
201
|
}
|
|
206
202
|
/**
|
|
207
203
|
* Convert a Substrait function argument to a string
|
|
@@ -216,15 +212,13 @@ class SubstraitParser {
|
|
|
216
212
|
}
|
|
217
213
|
return arg.enum.specified;
|
|
218
214
|
}
|
|
219
|
-
|
|
215
|
+
if (arg.type != null) {
|
|
220
216
|
return this.typeToField(arg.type).type;
|
|
221
217
|
}
|
|
222
|
-
|
|
218
|
+
if (arg.value != null) {
|
|
223
219
|
return this.expressionToStr(arg.value, inp).name;
|
|
224
220
|
}
|
|
225
|
-
|
|
226
|
-
throw new Error("A FunctionArgument did not have an enum/type/value");
|
|
227
|
-
}
|
|
221
|
+
throw new Error("A FunctionArgument did not have an enum/type/value");
|
|
228
222
|
}
|
|
229
223
|
/**
|
|
230
224
|
* Converts a Substrait function reference to a string
|
|
@@ -292,7 +286,7 @@ class SubstraitParser {
|
|
|
292
286
|
children: [],
|
|
293
287
|
};
|
|
294
288
|
}
|
|
295
|
-
|
|
289
|
+
if (lit.date != null) {
|
|
296
290
|
return {
|
|
297
291
|
name: new Date((lit.date?.value ?? 0) * 8.64e7).toISOString(),
|
|
298
292
|
type: "date",
|
|
@@ -300,7 +294,7 @@ class SubstraitParser {
|
|
|
300
294
|
children: [],
|
|
301
295
|
};
|
|
302
296
|
}
|
|
303
|
-
|
|
297
|
+
if (lit.decimal != null) {
|
|
304
298
|
return {
|
|
305
299
|
name: String(this.base64ToDecimal(lit.decimal.value ?? "", lit.decimal.precision, lit.decimal.scale)),
|
|
306
300
|
type: "decimal",
|
|
@@ -308,7 +302,7 @@ class SubstraitParser {
|
|
|
308
302
|
children: [],
|
|
309
303
|
};
|
|
310
304
|
}
|
|
311
|
-
|
|
305
|
+
if (lit.i32 != null) {
|
|
312
306
|
return {
|
|
313
307
|
name: lit.i32?.value?.toString() ?? "unspecified",
|
|
314
308
|
type: "i32",
|
|
@@ -316,7 +310,7 @@ class SubstraitParser {
|
|
|
316
310
|
children: [],
|
|
317
311
|
};
|
|
318
312
|
}
|
|
319
|
-
|
|
313
|
+
if (lit.intervalDayToSecond != null) {
|
|
320
314
|
const val = lit.intervalDayToSecond;
|
|
321
315
|
return {
|
|
322
316
|
name: `${val.days}d${val.seconds}s${val.microseconds}u`,
|
|
@@ -325,7 +319,7 @@ class SubstraitParser {
|
|
|
325
319
|
children: [],
|
|
326
320
|
};
|
|
327
321
|
}
|
|
328
|
-
|
|
322
|
+
if (lit.fixedChar != null) {
|
|
329
323
|
const val = typeof lit.fixedChar === "string"
|
|
330
324
|
? lit.fixedChar
|
|
331
325
|
: lit.fixedChar.value ?? "unspecified";
|
|
@@ -336,9 +330,7 @@ class SubstraitParser {
|
|
|
336
330
|
children: [],
|
|
337
331
|
};
|
|
338
332
|
}
|
|
339
|
-
|
|
340
|
-
throw new Error(`Unrecognized literal: ${JSON.stringify(lit)}`);
|
|
341
|
-
}
|
|
333
|
+
throw new Error(`Unrecognized literal: ${JSON.stringify(lit)}`);
|
|
342
334
|
}
|
|
343
335
|
/**
|
|
344
336
|
* Convert a cast expression to a stringified representation
|
|
@@ -375,18 +367,16 @@ class SubstraitParser {
|
|
|
375
367
|
if (expr.selection != null) {
|
|
376
368
|
return this.referenceToField(expr.selection, exprIn);
|
|
377
369
|
}
|
|
378
|
-
|
|
370
|
+
if (expr.scalarFunction != null) {
|
|
379
371
|
return this.scalarFunctionToField(expr.scalarFunction, exprIn);
|
|
380
372
|
}
|
|
381
|
-
|
|
373
|
+
if (expr.literal != null) {
|
|
382
374
|
return this.literalToField(expr.literal);
|
|
383
375
|
}
|
|
384
|
-
|
|
376
|
+
if (expr.cast != null) {
|
|
385
377
|
return this.castToField(expr.cast, exprIn);
|
|
386
378
|
}
|
|
387
|
-
|
|
388
|
-
throw new Error(`Unrecognized expression: ${JSON.stringify(expr)}`);
|
|
389
|
-
}
|
|
379
|
+
throw new Error(`Unrecognized expression: ${JSON.stringify(expr)}`);
|
|
390
380
|
}
|
|
391
381
|
/**
|
|
392
382
|
* Convert a project relation to a print node
|
|
@@ -630,14 +620,14 @@ class SubstraitParser {
|
|
|
630
620
|
const input = this.relToNode(agg.input);
|
|
631
621
|
const props = [];
|
|
632
622
|
const fields = [];
|
|
633
|
-
agg.groupings.
|
|
623
|
+
for (const [idx, grouping] of agg.groupings.entries()) {
|
|
634
624
|
for (const groupingExpr of grouping.groupingExpressions) {
|
|
635
625
|
const groupingField = this.expressionToStr(groupingExpr, input.schema);
|
|
636
626
|
props.push({ name: `grouping[${idx}]`, value: groupingField.name });
|
|
637
627
|
fields.push(groupingField);
|
|
638
628
|
}
|
|
639
|
-
}
|
|
640
|
-
agg.measures.
|
|
629
|
+
}
|
|
630
|
+
for (const [idx, measure] of agg.measures.entries()) {
|
|
641
631
|
const aggregate = this.aggregateFunctionToField(measure.measure, input.schema);
|
|
642
632
|
fields.push(aggregate);
|
|
643
633
|
const innerProps = [
|
|
@@ -654,7 +644,7 @@ class SubstraitParser {
|
|
|
654
644
|
name: `measures[${idx}]`,
|
|
655
645
|
value: JSON.stringify(innerProps), // TODO Is this right?
|
|
656
646
|
});
|
|
657
|
-
}
|
|
647
|
+
}
|
|
658
648
|
const schema = this.makeSchemaField(fields);
|
|
659
649
|
return this.makePrintNode("aggregate", [input], props, schema, agg.common.emit);
|
|
660
650
|
}
|
|
@@ -704,27 +694,25 @@ class SubstraitParser {
|
|
|
704
694
|
if (rel.project != null) {
|
|
705
695
|
return this.projectToNode(rel.project);
|
|
706
696
|
}
|
|
707
|
-
|
|
697
|
+
if (rel.read != null) {
|
|
708
698
|
return this.readToNode(rel.read);
|
|
709
699
|
}
|
|
710
|
-
|
|
700
|
+
if (rel.fetch != null) {
|
|
711
701
|
return this.fetchToNode(rel.fetch);
|
|
712
702
|
}
|
|
713
|
-
|
|
703
|
+
if (rel.sort != null) {
|
|
714
704
|
return this.sortToNode(rel.sort);
|
|
715
705
|
}
|
|
716
|
-
|
|
706
|
+
if (rel.aggregate != null) {
|
|
717
707
|
return this.aggToNode(rel.aggregate);
|
|
718
708
|
}
|
|
719
|
-
|
|
709
|
+
if (rel.filter != null) {
|
|
720
710
|
return this.filterToNode(rel.filter);
|
|
721
711
|
}
|
|
722
|
-
|
|
712
|
+
if (rel.join != null) {
|
|
723
713
|
return this.joinToNode(rel.join);
|
|
724
714
|
}
|
|
725
|
-
|
|
726
|
-
throw new Error(`Unrecognized relation: ${JSON.stringify(rel)}`);
|
|
727
|
-
}
|
|
715
|
+
throw new Error(`Unrecognized relation: ${JSON.stringify(rel)}`);
|
|
728
716
|
}
|
|
729
717
|
/**
|
|
730
718
|
* Converts a Substrait root relation to a print node
|
|
@@ -788,7 +776,7 @@ class SubstraitParser {
|
|
|
788
776
|
for (let i = buffer.length - 1; i >= 0; i--) {
|
|
789
777
|
value = (value << BigInt(8)) + BigInt(buffer[i]);
|
|
790
778
|
}
|
|
791
|
-
return Number(value) /
|
|
779
|
+
return Number(value) / 10 ** scale;
|
|
792
780
|
}
|
|
793
781
|
deduplicate(array) {
|
|
794
782
|
return Array.from(new Set(array));
|
package/build/nql/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseApi } from "../base-api";
|
|
2
|
-
import {
|
|
3
|
-
import type { Nql,
|
|
2
|
+
import type { NqlAst } from "./Ast";
|
|
3
|
+
import type { Nql, NqlBooleanExpression, NqlCompileResult, NqlExpression, NqlField, NqlFilterBinaryExpression, NqlFilterExpression, NqlFilterUnaryExpression, NqlQueryInput, NqlResult, NqlWhere } from "./types";
|
|
4
4
|
/**
|
|
5
5
|
* A class for accessing the NQL API.
|
|
6
6
|
* @extends BaseApi
|
package/build/nql/types.d.ts
CHANGED
package/build/ping/index.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* @fileoverview This module provides methods for fetching resources.
|
|
3
3
|
* @author Your Name
|
|
4
4
|
*/
|
|
5
|
-
import { type ApiRecords } from "../types";
|
|
6
5
|
import { BaseApi } from "../base-api";
|
|
7
|
-
import
|
|
8
|
-
|
|
6
|
+
import type { ApiRecords } from "../types";
|
|
7
|
+
import type { BucketCreationRequest, Resource, UpdateAccessTypeRequest } from "./types";
|
|
8
|
+
export type { Resource, BucketCreationRequest, UpdateAccessTypeRequest };
|
|
9
9
|
/**
|
|
10
10
|
* @class ResourceApi
|
|
11
11
|
* @extends {BaseApi}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Mapping } from "src/mappings/types";
|
|
2
2
|
import { BaseApi } from "../base-api";
|
|
3
|
-
import type { RosettaStoneResponse,
|
|
3
|
+
import type { RosettaStoneResponse, SampleRecord, SampleRecords } from "./types";
|
|
4
4
|
declare class RosettaStoneApi extends BaseApi {
|
|
5
5
|
getLabelsFromSample(sample: SampleRecords): Promise<RosettaStoneResponse[]>;
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type ApiRecords } from "../types";
|
|
2
1
|
import { BaseApi } from "../base-api";
|
|
3
|
-
import
|
|
2
|
+
import type { ApiRecords } from "../types";
|
|
3
|
+
import type { DataStreamSubscriptionDetails, MarketplaceSubscriptionDetails, Subscription, SubscriptionBudget, SubscriptionDetails, SubscriptionOutput, SubscriptionStatus, SubscriptionType } from "./types";
|
|
4
4
|
/**
|
|
5
5
|
* @module SubscriptionsApi
|
|
6
6
|
* @description This module provides methods for interacing with subscriptions
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { CompanyConstraint, DataRules, Offer } from "src/data-streams/types";
|
|
2
|
+
import type { DatasetConstraint } from "src/forecast/types";
|
|
3
3
|
export interface Subscription {
|
|
4
4
|
id: string;
|
|
5
5
|
budget: SubscriptionBudget;
|
package/build/uploads/index.d.ts
CHANGED