@malloydata/malloy 0.0.334 → 0.0.336
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/CONTEXT.md +4 -3
- package/MALLOY_API.md +129 -0
- package/dist/annotation.d.ts +0 -2
- package/dist/annotation.js +29 -23
- package/dist/api/asynchronous.d.ts +1 -1
- package/dist/api/foundation/cache.d.ts +32 -0
- package/dist/api/foundation/cache.js +92 -0
- package/dist/api/foundation/compile.d.ts +175 -0
- package/dist/api/foundation/compile.js +391 -0
- package/dist/api/foundation/core.d.ts +493 -0
- package/dist/api/foundation/core.js +1247 -0
- package/dist/api/foundation/document.d.ts +167 -0
- package/dist/api/foundation/document.js +206 -0
- package/dist/api/foundation/index.d.ts +10 -0
- package/dist/api/foundation/index.js +77 -0
- package/dist/api/foundation/readers.d.ts +53 -0
- package/dist/api/foundation/readers.js +134 -0
- package/dist/api/foundation/result.d.ts +185 -0
- package/dist/api/foundation/result.js +704 -0
- package/dist/api/foundation/runtime.d.ts +361 -0
- package/dist/api/foundation/runtime.js +733 -0
- package/dist/api/foundation/types.d.ts +54 -0
- package/dist/api/foundation/types.js +7 -0
- package/dist/api/foundation/writers.d.ts +42 -0
- package/dist/api/foundation/writers.js +230 -0
- package/dist/api/util.d.ts +1 -1
- package/dist/connection/base_connection.d.ts +5 -0
- package/dist/connection/types.d.ts +5 -0
- package/dist/dialect/duckdb/duckdb.js +2 -1
- package/dist/dialect/snowflake/snowflake.js +7 -1
- package/dist/dialect/trino/trino.js +7 -2
- package/dist/index.d.ts +6 -3
- package/dist/index.js +30 -26
- package/dist/lang/ast/error-factory.js +3 -5
- package/dist/lang/ast/expressions/expr-count-distinct.js +7 -1
- package/dist/lang/ast/expressions/expr-granular-time.js +1 -1
- package/dist/lang/ast/expressions/expr-max.js +7 -1
- package/dist/lang/ast/expressions/expr-min.js +7 -1
- package/dist/lang/ast/expressions/for-range.js +1 -1
- package/dist/lang/ast/source-elements/query-source.js +2 -7
- package/dist/lang/ast/source-elements/refined-source.js +11 -1
- package/dist/lang/ast/source-elements/sql-source.d.ts +1 -1
- package/dist/lang/ast/source-elements/sql-source.js +18 -3
- package/dist/lang/ast/sql-elements/sql-string.d.ts +2 -2
- package/dist/lang/ast/sql-elements/sql-string.js +18 -1
- package/dist/lang/ast/statements/define-source.js +7 -2
- package/dist/lang/ast/statements/import-statement.js +53 -21
- package/dist/lang/ast/types/document-compile-result.d.ts +1 -0
- package/dist/lang/ast/types/expression-def.js +1 -1
- package/dist/lang/ast/types/malloy-element.d.ts +3 -1
- package/dist/lang/ast/types/malloy-element.js +23 -7
- package/dist/lang/malloy-to-ast.d.ts +1 -1
- package/dist/lang/malloy-to-ast.js +1 -1
- package/dist/lang/parse-malloy.d.ts +3 -2
- package/dist/lang/parse-malloy.js +14 -25
- package/dist/lang/test/test-translator.d.ts +9 -2
- package/dist/lang/test/test-translator.js +103 -77
- package/dist/lang/translate-response.d.ts +1 -0
- package/dist/model/constant_expression_compiler.js +6 -7
- package/dist/model/index.d.ts +3 -1
- package/dist/model/index.js +15 -9
- package/dist/model/malloy_types.d.ts +89 -15
- package/dist/model/malloy_types.js +12 -0
- package/dist/model/persist_utils.d.ts +47 -0
- package/dist/model/persist_utils.js +257 -0
- package/dist/model/query_model_impl.d.ts +2 -4
- package/dist/model/query_model_impl.js +5 -13
- package/dist/model/query_node.d.ts +1 -2
- package/dist/model/query_node.js +3 -13
- package/dist/model/query_query.d.ts +17 -1
- package/dist/model/query_query.js +81 -36
- package/dist/model/source_def_utils.d.ts +50 -0
- package/dist/model/source_def_utils.js +154 -0
- package/dist/model/sql_block.d.ts +5 -1
- package/dist/model/sql_block.js +29 -4
- package/dist/model/sql_compiled.d.ts +29 -0
- package/dist/model/sql_compiled.js +102 -0
- package/dist/model/stage_writer.d.ts +1 -3
- package/dist/model/stage_writer.js +7 -25
- package/dist/model/utils.d.ts +20 -1
- package/dist/model/utils.js +40 -0
- package/dist/run_sql_options.d.ts +0 -1
- package/dist/taggable.d.ts +10 -0
- package/dist/taggable.js +7 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -4
- package/dist/malloy.d.ts +0 -1365
- package/dist/malloy.js +0 -3421
- package/dist/model/materialization/utils.d.ts +0 -3
- package/dist/model/materialization/utils.js +0 -41
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { EventStream } from '../../runtime_types';
|
|
2
|
+
import type { BuildManifest } from '../../model';
|
|
3
|
+
export type { Taggable } from '../../taggable';
|
|
4
|
+
export interface Loggable {
|
|
5
|
+
debug: (message?: any, ...optionalParams: any[]) => void;
|
|
6
|
+
info: (message?: any, ...optionalParams: any[]) => void;
|
|
7
|
+
warn: (message?: any, ...optionalParams: any[]) => void;
|
|
8
|
+
error: (message?: any, ...optionalParams: any[]) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface ParseOptions {
|
|
11
|
+
importBaseURL?: URL;
|
|
12
|
+
testEnvironment?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Options for how to run the Malloy semantic checker/translator */
|
|
15
|
+
export interface CompileOptions {
|
|
16
|
+
refreshSchemaCache?: boolean | number;
|
|
17
|
+
noThrowOnError?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Options given to the Malloy compiler (QueryModel) */
|
|
20
|
+
export interface CompileQueryOptions {
|
|
21
|
+
eventStream?: EventStream;
|
|
22
|
+
defaultRowLimit?: number;
|
|
23
|
+
/** Manifest of built tables (BuildID → entry) for persist substitution */
|
|
24
|
+
buildManifest?: BuildManifest;
|
|
25
|
+
/** Map from connectionName to connectionDigest (from Connection.getDigest()) */
|
|
26
|
+
connectionDigests?: Record<string, string>;
|
|
27
|
+
/** If true, throw when a persist source's BuildID is not in the manifest */
|
|
28
|
+
strictPersist?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A node in the build graph (recursive DAG structure).
|
|
32
|
+
* Uses sourceID (sourceName@modelURL) for identity.
|
|
33
|
+
*/
|
|
34
|
+
export interface BuildNode {
|
|
35
|
+
/** Source identity: "sourceName@modelURL" */
|
|
36
|
+
sourceID: string;
|
|
37
|
+
/** Dependencies as nested BuildNodes (recursive DAG) */
|
|
38
|
+
dependsOn: BuildNode[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* An ordered build plan for sources on a single connection.
|
|
42
|
+
*
|
|
43
|
+
* The leveled array structure determines build order: sources in the same
|
|
44
|
+
* level can be built in parallel, levels must be built sequentially.
|
|
45
|
+
*
|
|
46
|
+
* Builders can group graphs by `connectionName` to parallelize across
|
|
47
|
+
* different database connections.
|
|
48
|
+
*/
|
|
49
|
+
export interface BuildGraph {
|
|
50
|
+
/** The connection all sources in this graph run on */
|
|
51
|
+
connectionName: string;
|
|
52
|
+
/** The leveled build nodes */
|
|
53
|
+
nodes: BuildNode[][];
|
|
54
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { DataRecord } from './result';
|
|
2
|
+
export interface WriteStream {
|
|
3
|
+
write: (text: string) => void;
|
|
4
|
+
close: () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare abstract class DataWriter {
|
|
7
|
+
protected readonly stream: WriteStream;
|
|
8
|
+
constructor(stream: WriteStream);
|
|
9
|
+
abstract process(data: AsyncIterableIterator<DataRecord>): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare class JSONWriter extends DataWriter {
|
|
12
|
+
process(data: AsyncIterableIterator<DataRecord>): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* CSV writer class that handles nested data.
|
|
16
|
+
* This writer creates CSV using a DFS traversal of the result dataset.
|
|
17
|
+
* Each trivial column value is converted to a CSV of 1x1 matrix and all the
|
|
18
|
+
* columns are merged together to create a CSV that represents 1 QueryDataRow.
|
|
19
|
+
* Since this follows DFS, each non trivial data is rendered into a NxM matrix
|
|
20
|
+
* where N is the number of rows in the nested data and M is the number of
|
|
21
|
+
* columns it has.
|
|
22
|
+
* For any row with X number of columns, we end up with X number of NxM matrices
|
|
23
|
+
* where the value of N,M pair may be different for each column.
|
|
24
|
+
* We then merge the matrices so that we end up with a larger matrix of size
|
|
25
|
+
* Max(N)xSum(M) by taking one row of csv from each matric at a time. For any
|
|
26
|
+
* matrix with N<Max(N), we add a row of empty CSV cells of size N.
|
|
27
|
+
*/
|
|
28
|
+
export declare class CSVWriter extends DataWriter {
|
|
29
|
+
private readonly columnSeparator;
|
|
30
|
+
private readonly rowSeparator;
|
|
31
|
+
private readonly quoteCharacter;
|
|
32
|
+
private readonly includeHeader;
|
|
33
|
+
private readonly emptyCell;
|
|
34
|
+
private escape;
|
|
35
|
+
private stringify;
|
|
36
|
+
private getColWeight;
|
|
37
|
+
private getHeaderRow;
|
|
38
|
+
private mergeMatrices;
|
|
39
|
+
private getChildMatrix;
|
|
40
|
+
private getRowMatrix;
|
|
41
|
+
process(data: AsyncIterableIterator<DataRecord>): Promise<void>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Contributors to the Malloy project
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.CSVWriter = exports.JSONWriter = exports.DataWriter = void 0;
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// DataWriter Base Class
|
|
10
|
+
// =============================================================================
|
|
11
|
+
class DataWriter {
|
|
12
|
+
constructor(stream) {
|
|
13
|
+
this.stream = stream;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.DataWriter = DataWriter;
|
|
17
|
+
// =============================================================================
|
|
18
|
+
// JSONWriter
|
|
19
|
+
// =============================================================================
|
|
20
|
+
class JSONWriter extends DataWriter {
|
|
21
|
+
async process(data) {
|
|
22
|
+
this.stream.write('[\n');
|
|
23
|
+
for await (const row of data) {
|
|
24
|
+
if (row.index !== undefined && row.index > 0) {
|
|
25
|
+
this.stream.write(',\n');
|
|
26
|
+
}
|
|
27
|
+
// toJSON() returns JSON-safe values: bigints as strings, dates as ISO strings
|
|
28
|
+
const json = JSON.stringify(row.toJSON(), null, 2);
|
|
29
|
+
const jsonLines = json.split('\n');
|
|
30
|
+
for (let i = 0; i < jsonLines.length; i++) {
|
|
31
|
+
const line = jsonLines[i];
|
|
32
|
+
this.stream.write(` ${line}`);
|
|
33
|
+
if (i < jsonLines.length - 1) {
|
|
34
|
+
this.stream.write('\n');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
this.stream.write('\n]\n');
|
|
39
|
+
this.stream.close();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.JSONWriter = JSONWriter;
|
|
43
|
+
// =============================================================================
|
|
44
|
+
// CSVWriter
|
|
45
|
+
// =============================================================================
|
|
46
|
+
/**
|
|
47
|
+
* CSV writer class that handles nested data.
|
|
48
|
+
* This writer creates CSV using a DFS traversal of the result dataset.
|
|
49
|
+
* Each trivial column value is converted to a CSV of 1x1 matrix and all the
|
|
50
|
+
* columns are merged together to create a CSV that represents 1 QueryDataRow.
|
|
51
|
+
* Since this follows DFS, each non trivial data is rendered into a NxM matrix
|
|
52
|
+
* where N is the number of rows in the nested data and M is the number of
|
|
53
|
+
* columns it has.
|
|
54
|
+
* For any row with X number of columns, we end up with X number of NxM matrices
|
|
55
|
+
* where the value of N,M pair may be different for each column.
|
|
56
|
+
* We then merge the matrices so that we end up with a larger matrix of size
|
|
57
|
+
* Max(N)xSum(M) by taking one row of csv from each matric at a time. For any
|
|
58
|
+
* matrix with N<Max(N), we add a row of empty CSV cells of size N.
|
|
59
|
+
*/
|
|
60
|
+
class CSVWriter extends DataWriter {
|
|
61
|
+
constructor() {
|
|
62
|
+
super(...arguments);
|
|
63
|
+
this.columnSeparator = ',';
|
|
64
|
+
this.rowSeparator = '\n';
|
|
65
|
+
this.quoteCharacter = '"';
|
|
66
|
+
this.includeHeader = true;
|
|
67
|
+
this.emptyCell = '';
|
|
68
|
+
}
|
|
69
|
+
escape(value) {
|
|
70
|
+
const hasInnerQuote = value.includes(this.quoteCharacter);
|
|
71
|
+
const hasInnerCommas = value.includes(this.columnSeparator);
|
|
72
|
+
const hasNewline = value.includes(this.rowSeparator);
|
|
73
|
+
const needsQuoting = hasInnerCommas || hasInnerQuote || hasNewline;
|
|
74
|
+
if (hasInnerQuote) {
|
|
75
|
+
value = value.replace(new RegExp(this.quoteCharacter, 'g'), this.quoteCharacter + this.quoteCharacter);
|
|
76
|
+
}
|
|
77
|
+
if (needsQuoting) {
|
|
78
|
+
value = this.quoteCharacter + value + this.quoteCharacter;
|
|
79
|
+
}
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
// Re-using the old stringify method for sanity.
|
|
83
|
+
stringify(value) {
|
|
84
|
+
if (value === null) {
|
|
85
|
+
return this.emptyCell;
|
|
86
|
+
}
|
|
87
|
+
else if (value instanceof Date) {
|
|
88
|
+
return value.toISOString();
|
|
89
|
+
}
|
|
90
|
+
else if (typeof value === 'boolean' || typeof value === 'number') {
|
|
91
|
+
return JSON.stringify(value);
|
|
92
|
+
}
|
|
93
|
+
else if (typeof value === 'bigint') {
|
|
94
|
+
// Bigints from toObject() - write as unquoted number string
|
|
95
|
+
return value.toString();
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return `${value}`;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Extra weight to be added becase of nested tables inside the cells.
|
|
102
|
+
getColWeight(jsonVal) {
|
|
103
|
+
let firstVal = jsonVal;
|
|
104
|
+
if (Array.isArray(jsonVal)) {
|
|
105
|
+
firstVal = jsonVal[0];
|
|
106
|
+
}
|
|
107
|
+
let numKeys = 0;
|
|
108
|
+
for (const key in firstVal) {
|
|
109
|
+
numKeys = numKeys + 1;
|
|
110
|
+
const val = firstVal[key];
|
|
111
|
+
if (Array.isArray(val)) {
|
|
112
|
+
const weight = this.getColWeight(val) - 1;
|
|
113
|
+
numKeys = numKeys + weight;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return numKeys;
|
|
117
|
+
}
|
|
118
|
+
// Get header row along with extra empty spaces for nested children.
|
|
119
|
+
getHeaderRow(row) {
|
|
120
|
+
const csv = [];
|
|
121
|
+
let width = 0;
|
|
122
|
+
for (const key in row) {
|
|
123
|
+
csv.push(this.escape(key));
|
|
124
|
+
const val = row[key];
|
|
125
|
+
width++;
|
|
126
|
+
if (Array.isArray(val)) {
|
|
127
|
+
const numKeys = this.getColWeight(val) - 1;
|
|
128
|
+
width = width + numKeys;
|
|
129
|
+
for (let i = 0; i < numKeys; i++) {
|
|
130
|
+
csv.push(this.emptyCell);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return { rows: [csv.join(this.columnSeparator)], length: 1, width: width };
|
|
135
|
+
}
|
|
136
|
+
// Merge the child matrices i.e. merge the columns into one bigger matrix i.e. CSV.
|
|
137
|
+
mergeMatrices(matrices) {
|
|
138
|
+
const maxLength = Math.max(...matrices.map(matrix => matrix.length));
|
|
139
|
+
const matrixWidth = matrices.reduce((sum, matrix) => sum + matrix.width, 0);
|
|
140
|
+
const csvMatrix = [];
|
|
141
|
+
for (let i = 0; i < maxLength; i++) {
|
|
142
|
+
const csvRow = [];
|
|
143
|
+
for (const matrix of matrices) {
|
|
144
|
+
if (i < matrix.length) {
|
|
145
|
+
csvRow.push(matrix.rows[i]);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// Add empty cells.
|
|
149
|
+
const emptyCells = Array(matrix.width).fill(this.emptyCell);
|
|
150
|
+
csvRow.push(...emptyCells);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
csvMatrix.push(csvRow.join(this.columnSeparator));
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
rows: csvMatrix,
|
|
157
|
+
length: maxLength,
|
|
158
|
+
width: matrixWidth,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
// Gets CSV for a data cell that has nested data.
|
|
162
|
+
getChildMatrix(jsonVal) {
|
|
163
|
+
// This is not expected to happen.
|
|
164
|
+
if (!Array.isArray(jsonVal)) {
|
|
165
|
+
return {
|
|
166
|
+
rows: ['Invalid data found, value is not an array'],
|
|
167
|
+
length: 1,
|
|
168
|
+
width: 1,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
else if (jsonVal.length === 0) {
|
|
172
|
+
return {
|
|
173
|
+
rows: [''],
|
|
174
|
+
length: 1,
|
|
175
|
+
width: 1,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const csvMatrix = [];
|
|
179
|
+
const header = this.getHeaderRow(jsonVal[0]);
|
|
180
|
+
// Header has 1 row.
|
|
181
|
+
csvMatrix.push(...header.rows);
|
|
182
|
+
const width = header.width;
|
|
183
|
+
let rowCount = 1;
|
|
184
|
+
for (const row of jsonVal) {
|
|
185
|
+
const rowMatrix = this.getRowMatrix(row);
|
|
186
|
+
rowCount = rowCount + rowMatrix.length;
|
|
187
|
+
csvMatrix.push(...rowMatrix.rows);
|
|
188
|
+
}
|
|
189
|
+
return { rows: csvMatrix, length: rowCount, width: width };
|
|
190
|
+
}
|
|
191
|
+
// Creates CSV content for one row of data.
|
|
192
|
+
getRowMatrix(row) {
|
|
193
|
+
const matrices = [];
|
|
194
|
+
for (const key in row) {
|
|
195
|
+
const val = row[key];
|
|
196
|
+
if (!Array.isArray(val)) {
|
|
197
|
+
const cell = {
|
|
198
|
+
rows: [this.stringify(val)],
|
|
199
|
+
length: 1,
|
|
200
|
+
width: 1,
|
|
201
|
+
};
|
|
202
|
+
matrices.push(cell);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
const cell = this.getChildMatrix(val);
|
|
206
|
+
matrices.push(cell);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return this.mergeMatrices(matrices);
|
|
210
|
+
}
|
|
211
|
+
async process(data) {
|
|
212
|
+
let headerDefined = false;
|
|
213
|
+
for await (const row of data) {
|
|
214
|
+
if (!headerDefined && this.includeHeader) {
|
|
215
|
+
const header = this.getHeaderRow(row.toObject());
|
|
216
|
+
this.stream.write(header.rows[0]);
|
|
217
|
+
this.stream.write(this.rowSeparator);
|
|
218
|
+
headerDefined = true;
|
|
219
|
+
}
|
|
220
|
+
const rowCsv = this.getRowMatrix(row.toObject());
|
|
221
|
+
for (const line of rowCsv.rows) {
|
|
222
|
+
this.stream.write(line);
|
|
223
|
+
this.stream.write(this.rowSeparator);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
this.stream.close();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.CSVWriter = CSVWriter;
|
|
230
|
+
//# sourceMappingURL=writers.js.map
|
package/dist/api/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfoConnection as LegacyInfoConnection, Connection as LegacyConnection } from '../connection';
|
|
2
|
-
import type { Result } from '
|
|
2
|
+
import type { Result } from './foundation';
|
|
3
3
|
import type { Expr } from '../model';
|
|
4
4
|
import { type QueryData } from '../model';
|
|
5
5
|
import type { Connection, InfoConnection } from './connection';
|
|
@@ -16,6 +16,11 @@ export declare abstract class BaseConnection implements Connection {
|
|
|
16
16
|
abstract runSQL(sql: string, options?: RunSQLOptions | undefined): Promise<MalloyQueryData>;
|
|
17
17
|
abstract get name(): string;
|
|
18
18
|
abstract get dialectName(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Get a digest identifying this connection's target database.
|
|
21
|
+
* Used for cache key computation in persist manifests.
|
|
22
|
+
*/
|
|
23
|
+
abstract getDigest(): string;
|
|
19
24
|
abstract fetchTableSchema(tableName: string, tablePath: string): Promise<TableSourceDef | string>;
|
|
20
25
|
abstract fetchSelectSchema(sqlSource: SQLSourceRequest): Promise<SQLSourceDef | string>;
|
|
21
26
|
protected schemaCache: Record<string, CachedSchema<StructDef>>;
|
|
@@ -42,6 +42,11 @@ export interface InfoConnection {
|
|
|
42
42
|
*/
|
|
43
43
|
get name(): string;
|
|
44
44
|
get dialectName(): string;
|
|
45
|
+
/**
|
|
46
|
+
* Get a digest identifying this connection's target database.
|
|
47
|
+
* Used for cache key computation in persist manifests.
|
|
48
|
+
*/
|
|
49
|
+
getDigest(): string;
|
|
45
50
|
}
|
|
46
51
|
export type ConnectionParameterValue = string | number | boolean | Array<ConnectionParameterValue>;
|
|
47
52
|
export interface ConnectionParameter {
|
|
@@ -86,7 +86,8 @@ class DuckDBDialect extends pg_impl_1.PostgresBase {
|
|
|
86
86
|
return `__udf${Math.floor(Math.random() * 100000)}`;
|
|
87
87
|
}
|
|
88
88
|
quoteTablePath(tableName) {
|
|
89
|
-
|
|
89
|
+
// Quote if contains special chars that could be SQL injection or need quoting
|
|
90
|
+
return tableName.match(/[/*:;-]/) ? `'${tableName}'` : tableName;
|
|
90
91
|
}
|
|
91
92
|
sqlGroupSetTable(groupSetCount) {
|
|
92
93
|
return `CROSS JOIN (SELECT UNNEST(GENERATE_SERIES(0,${groupSetCount},1)) as group_set ) as group_set`;
|
|
@@ -103,8 +103,14 @@ class SnowflakeDialect extends dialect_1.Dialect {
|
|
|
103
103
|
{ min: dialect_1.MIN_DECIMAL38, max: dialect_1.MAX_DECIMAL38, numberType: 'bigint' },
|
|
104
104
|
];
|
|
105
105
|
}
|
|
106
|
-
// don't mess with the table pathing.
|
|
107
106
|
quoteTablePath(tablePath) {
|
|
107
|
+
// Quote with double quotes if contains dangerous characters
|
|
108
|
+
if (tablePath.match(/[;-]/)) {
|
|
109
|
+
return tablePath
|
|
110
|
+
.split('.')
|
|
111
|
+
.map(part => `"${part}"`)
|
|
112
|
+
.join('.');
|
|
113
|
+
}
|
|
108
114
|
return tablePath;
|
|
109
115
|
}
|
|
110
116
|
sqlGroupSetTable(groupSetCount) {
|
|
@@ -201,8 +201,13 @@ class TrinoDialect extends pg_impl_1.PostgresBase {
|
|
|
201
201
|
WITHIN`.split(/\s/);
|
|
202
202
|
}
|
|
203
203
|
quoteTablePath(tablePath) {
|
|
204
|
-
//
|
|
205
|
-
|
|
204
|
+
// Quote with double quotes if contains dangerous characters
|
|
205
|
+
if (tablePath.match(/[;-]/)) {
|
|
206
|
+
return tablePath
|
|
207
|
+
.split('.')
|
|
208
|
+
.map(part => `"${part}"`)
|
|
209
|
+
.join('.');
|
|
210
|
+
}
|
|
206
211
|
return tablePath;
|
|
207
212
|
}
|
|
208
213
|
sqlGroupSetTable(groupSetCount) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { DuckDBDialect, StandardSQLDialect, TrinoDialect, PostgresDialect, SnowflakeDialect, MySQLDialect, registerDialect, arg, qtz, overload, minScalar, anyExprType, minAggregate, maxScalar, sql, makeParam, param, variadicParam, literal, spread, Dialect, TinyParser, } from './dialect';
|
|
2
2
|
export type { DialectFieldList, DialectFunctionOverloadDef, QueryInfo, MalloyStandardFunctionImplementations, DefinitionBlueprint, DefinitionBlueprintMap, OverloadedDefinitionBlueprint, TinyToken, } from './dialect';
|
|
3
|
-
export type { QueryDataRow, StructDef, TableSourceDef, SQLSourceDef, SourceDef, JoinFieldDef, NamedSourceDefs, MalloyQueryData, DateUnit, ExtractUnit, TimestampUnit, TemporalFieldType, QueryData, QueryValue, Expr, FilterCondition, Argument, Parameter, FieldDef, PipeSegment, QueryFieldDef, IndexFieldDef, TurtleDef, SearchValueMapResult, SearchIndexResult, ModelDef, Query, QueryResult, QueryResultDef, QueryRunStats, QueryScalar,
|
|
3
|
+
export type { QueryDataRow, StructDef, TableSourceDef, SQLSourceDef, SourceDef, JoinFieldDef, NamedSourceDefs, MalloyQueryData, DateUnit, ExtractUnit, TimestampUnit, TemporalFieldType, QueryData, QueryValue, Expr, FilterCondition, Argument, Parameter, FieldDef, PipeSegment, QueryFieldDef, IndexFieldDef, TurtleDef, SearchValueMapResult, SearchIndexResult, ModelDef, Query, QueryResult, QueryResultDef, QueryRunStats, QueryScalar, NamedQueryDef, NamedModelObject, ExpressionType, FunctionDef, FunctionOverloadDef, FunctionParameterDef, ExpressionValueType, TypeDesc, FunctionParamTypeDesc, DocumentLocation, DocumentRange, DocumentPosition, Sampling, Annotation, BasicAtomicTypeDef, BasicAtomicDef, AtomicTypeDef, AtomicFieldDef, ArrayDef, ArrayTypeDef, RecordTypeDef, RepeatedRecordTypeDef, RecordDef, RepeatedRecordDef, RecordLiteralNode, StringLiteralNode, ArrayLiteralNode, SourceComponentInfo, DateLiteralNode, TimestampLiteralNode, TimestamptzLiteralNode, TimeLiteralExpr, TypecastExpr, BuildManifest, BuildManifestEntry, } from './model';
|
|
4
4
|
export { isSourceDef, isBasicAtomic, isJoined, isJoinedSource, isSamplingEnable, isSamplingPercent, isSamplingRows, isRepeatedRecord, isBasicArray, mkArrayDef, mkFieldDef, expressionIsAggregate, expressionIsAnalytic, expressionIsCalculation, expressionIsScalar, expressionIsUngroupedAggregate, indent, composeSQLExpr, isTimestampUnit, isDateUnit, constantExprToSQL, } from './model';
|
|
5
5
|
export { malloyToQuery, MalloyTranslator, } from './lang';
|
|
6
6
|
export type { LogMessage, TranslateResponse } from './lang';
|
|
7
|
-
export { Model, Malloy, Runtime, AtomicFieldType, ConnectionRuntime, SingleConnectionRuntime, EmptyURLReader, InMemoryURLReader, FixedConnectionMap, MalloyError, JoinRelationship, SourceRelationship, DateTimeframe, TimestampTimeframe, PreparedResult, Result, QueryMaterializer, CSVWriter, JSONWriter, Parse, DataWriter, Explore, InMemoryModelCache, CacheManager, } from './
|
|
8
|
-
export type { PreparedQuery, Field, AtomicField, ExploreField, QueryField, SortableField, DataArray, DataRecord, DataColumn, DataArrayOrRecord, Loggable, ModelMaterializer, DocumentTablePath, DocumentSymbol, ResultJSON, PreparedResultJSON, PreparedResultMaterializer, ExploreMaterializer, WriteStream, SerializedExplore, ModelCache, CachedModel, DateField, TimestampField, } from './
|
|
7
|
+
export { Model, Malloy, Runtime, AtomicFieldType, ConnectionRuntime, SingleConnectionRuntime, EmptyURLReader, InMemoryURLReader, FixedConnectionMap, MalloyError, JoinRelationship, SourceRelationship, DateTimeframe, TimestampTimeframe, PreparedResult, Result, QueryMaterializer, CSVWriter, JSONWriter, Parse, DataWriter, Explore, InMemoryModelCache, CacheManager, } from './api/foundation';
|
|
8
|
+
export type { PreparedQuery, Field, AtomicField, ExploreField, QueryField, SortableField, DataArray, DataRecord, DataColumn, DataArrayOrRecord, Loggable, ModelMaterializer, DocumentTablePath, DocumentSymbol, ResultJSON, PreparedResultJSON, PreparedResultMaterializer, ExploreMaterializer, WriteStream, SerializedExplore, ModelCache, CachedModel, DateField, TimestampField, } from './api/foundation';
|
|
9
9
|
export type { QueryOptionsReader, RunSQLOptions } from './run_sql_options';
|
|
10
10
|
export type { EventStream, ModelString, ModelURL, QueryString, QueryURL, URLReader, InvalidationKey, } from './runtime_types';
|
|
11
11
|
export type { Connection, ConnectionConfig, ConnectionFactory, ConnectionParameter, ConnectionParameterValue, ConnectionConfigSchema, FetchSchemaOptions, InfoConnection, LookupConnection, PersistSQLResults, PooledConnection, TestableConnection, StreamingConnection, } from './connection/types';
|
|
@@ -15,3 +15,6 @@ export * as API from './api';
|
|
|
15
15
|
export type { SQLSourceRequest } from './lang/translate-response';
|
|
16
16
|
export { sqlKey } from './model/sql_block';
|
|
17
17
|
export { annotationToTag, annotationToTaglines } from './annotation';
|
|
18
|
+
export type { BuildGraph, BuildNode, BuildPlan } from './api/foundation';
|
|
19
|
+
export { PersistSource } from './api/foundation';
|
|
20
|
+
export { makeDigest } from './model';
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.ConnectionRuntime = exports.AtomicFieldType = exports.Runtime = exports.Malloy = exports.Model = exports.MalloyTranslator = exports.malloyToQuery = exports.constantExprToSQL = exports.isDateUnit = exports.isTimestampUnit = exports.composeSQLExpr = exports.indent = exports.expressionIsUngroupedAggregate = exports.expressionIsScalar = exports.expressionIsCalculation = exports.expressionIsAnalytic = exports.expressionIsAggregate = exports.mkFieldDef = exports.mkArrayDef = exports.isBasicArray = exports.isRepeatedRecord = exports.isSamplingRows = exports.isSamplingPercent = exports.isSamplingEnable = exports.isJoinedSource = exports.isJoined = exports.isBasicAtomic = exports.isSourceDef = exports.TinyParser = exports.Dialect = exports.spread = exports.literal = exports.variadicParam = exports.param = exports.makeParam = exports.sql = exports.maxScalar = exports.minAggregate = exports.anyExprType = exports.minScalar = exports.overload = exports.qtz = exports.arg = exports.registerDialect = exports.MySQLDialect = exports.SnowflakeDialect = exports.PostgresDialect = exports.TrinoDialect = exports.StandardSQLDialect = exports.DuckDBDialect = void 0;
|
|
37
|
-
exports.annotationToTaglines = exports.annotationToTag = exports.sqlKey = exports.API = exports.extractMalloyObjectFromTag = exports.writeMalloyObjectToTag = exports.sourceDefToSourceInfo = exports.modelDefToModelInfo = exports.toAsyncGenerator = exports.CacheManager = exports.InMemoryModelCache = exports.Explore = exports.DataWriter = exports.Parse = exports.JSONWriter = exports.CSVWriter = exports.QueryMaterializer = exports.Result = exports.PreparedResult = exports.TimestampTimeframe = exports.DateTimeframe = exports.SourceRelationship = exports.JoinRelationship = exports.MalloyError = exports.FixedConnectionMap = exports.InMemoryURLReader = exports.EmptyURLReader = exports.SingleConnectionRuntime = void 0;
|
|
37
|
+
exports.makeDigest = exports.PersistSource = exports.annotationToTaglines = exports.annotationToTag = exports.sqlKey = exports.API = exports.extractMalloyObjectFromTag = exports.writeMalloyObjectToTag = exports.sourceDefToSourceInfo = exports.modelDefToModelInfo = exports.toAsyncGenerator = exports.CacheManager = exports.InMemoryModelCache = exports.Explore = exports.DataWriter = exports.Parse = exports.JSONWriter = exports.CSVWriter = exports.QueryMaterializer = exports.Result = exports.PreparedResult = exports.TimestampTimeframe = exports.DateTimeframe = exports.SourceRelationship = exports.JoinRelationship = exports.MalloyError = exports.FixedConnectionMap = exports.InMemoryURLReader = exports.EmptyURLReader = exports.SingleConnectionRuntime = void 0;
|
|
38
38
|
/*
|
|
39
39
|
* Copyright 2023 Google LLC
|
|
40
40
|
*
|
|
@@ -108,31 +108,31 @@ var lang_1 = require("./lang");
|
|
|
108
108
|
Object.defineProperty(exports, "malloyToQuery", { enumerable: true, get: function () { return lang_1.malloyToQuery; } });
|
|
109
109
|
// Needed for tests only
|
|
110
110
|
Object.defineProperty(exports, "MalloyTranslator", { enumerable: true, get: function () { return lang_1.MalloyTranslator; } });
|
|
111
|
-
var
|
|
112
|
-
Object.defineProperty(exports, "Model", { enumerable: true, get: function () { return
|
|
113
|
-
Object.defineProperty(exports, "Malloy", { enumerable: true, get: function () { return
|
|
114
|
-
Object.defineProperty(exports, "Runtime", { enumerable: true, get: function () { return
|
|
115
|
-
Object.defineProperty(exports, "AtomicFieldType", { enumerable: true, get: function () { return
|
|
116
|
-
Object.defineProperty(exports, "ConnectionRuntime", { enumerable: true, get: function () { return
|
|
117
|
-
Object.defineProperty(exports, "SingleConnectionRuntime", { enumerable: true, get: function () { return
|
|
118
|
-
Object.defineProperty(exports, "EmptyURLReader", { enumerable: true, get: function () { return
|
|
119
|
-
Object.defineProperty(exports, "InMemoryURLReader", { enumerable: true, get: function () { return
|
|
120
|
-
Object.defineProperty(exports, "FixedConnectionMap", { enumerable: true, get: function () { return
|
|
121
|
-
Object.defineProperty(exports, "MalloyError", { enumerable: true, get: function () { return
|
|
122
|
-
Object.defineProperty(exports, "JoinRelationship", { enumerable: true, get: function () { return
|
|
123
|
-
Object.defineProperty(exports, "SourceRelationship", { enumerable: true, get: function () { return
|
|
124
|
-
Object.defineProperty(exports, "DateTimeframe", { enumerable: true, get: function () { return
|
|
125
|
-
Object.defineProperty(exports, "TimestampTimeframe", { enumerable: true, get: function () { return
|
|
126
|
-
Object.defineProperty(exports, "PreparedResult", { enumerable: true, get: function () { return
|
|
127
|
-
Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return
|
|
128
|
-
Object.defineProperty(exports, "QueryMaterializer", { enumerable: true, get: function () { return
|
|
129
|
-
Object.defineProperty(exports, "CSVWriter", { enumerable: true, get: function () { return
|
|
130
|
-
Object.defineProperty(exports, "JSONWriter", { enumerable: true, get: function () { return
|
|
131
|
-
Object.defineProperty(exports, "Parse", { enumerable: true, get: function () { return
|
|
132
|
-
Object.defineProperty(exports, "DataWriter", { enumerable: true, get: function () { return
|
|
133
|
-
Object.defineProperty(exports, "Explore", { enumerable: true, get: function () { return
|
|
134
|
-
Object.defineProperty(exports, "InMemoryModelCache", { enumerable: true, get: function () { return
|
|
135
|
-
Object.defineProperty(exports, "CacheManager", { enumerable: true, get: function () { return
|
|
111
|
+
var foundation_1 = require("./api/foundation");
|
|
112
|
+
Object.defineProperty(exports, "Model", { enumerable: true, get: function () { return foundation_1.Model; } });
|
|
113
|
+
Object.defineProperty(exports, "Malloy", { enumerable: true, get: function () { return foundation_1.Malloy; } });
|
|
114
|
+
Object.defineProperty(exports, "Runtime", { enumerable: true, get: function () { return foundation_1.Runtime; } });
|
|
115
|
+
Object.defineProperty(exports, "AtomicFieldType", { enumerable: true, get: function () { return foundation_1.AtomicFieldType; } });
|
|
116
|
+
Object.defineProperty(exports, "ConnectionRuntime", { enumerable: true, get: function () { return foundation_1.ConnectionRuntime; } });
|
|
117
|
+
Object.defineProperty(exports, "SingleConnectionRuntime", { enumerable: true, get: function () { return foundation_1.SingleConnectionRuntime; } });
|
|
118
|
+
Object.defineProperty(exports, "EmptyURLReader", { enumerable: true, get: function () { return foundation_1.EmptyURLReader; } });
|
|
119
|
+
Object.defineProperty(exports, "InMemoryURLReader", { enumerable: true, get: function () { return foundation_1.InMemoryURLReader; } });
|
|
120
|
+
Object.defineProperty(exports, "FixedConnectionMap", { enumerable: true, get: function () { return foundation_1.FixedConnectionMap; } });
|
|
121
|
+
Object.defineProperty(exports, "MalloyError", { enumerable: true, get: function () { return foundation_1.MalloyError; } });
|
|
122
|
+
Object.defineProperty(exports, "JoinRelationship", { enumerable: true, get: function () { return foundation_1.JoinRelationship; } });
|
|
123
|
+
Object.defineProperty(exports, "SourceRelationship", { enumerable: true, get: function () { return foundation_1.SourceRelationship; } });
|
|
124
|
+
Object.defineProperty(exports, "DateTimeframe", { enumerable: true, get: function () { return foundation_1.DateTimeframe; } });
|
|
125
|
+
Object.defineProperty(exports, "TimestampTimeframe", { enumerable: true, get: function () { return foundation_1.TimestampTimeframe; } });
|
|
126
|
+
Object.defineProperty(exports, "PreparedResult", { enumerable: true, get: function () { return foundation_1.PreparedResult; } });
|
|
127
|
+
Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return foundation_1.Result; } });
|
|
128
|
+
Object.defineProperty(exports, "QueryMaterializer", { enumerable: true, get: function () { return foundation_1.QueryMaterializer; } });
|
|
129
|
+
Object.defineProperty(exports, "CSVWriter", { enumerable: true, get: function () { return foundation_1.CSVWriter; } });
|
|
130
|
+
Object.defineProperty(exports, "JSONWriter", { enumerable: true, get: function () { return foundation_1.JSONWriter; } });
|
|
131
|
+
Object.defineProperty(exports, "Parse", { enumerable: true, get: function () { return foundation_1.Parse; } });
|
|
132
|
+
Object.defineProperty(exports, "DataWriter", { enumerable: true, get: function () { return foundation_1.DataWriter; } });
|
|
133
|
+
Object.defineProperty(exports, "Explore", { enumerable: true, get: function () { return foundation_1.Explore; } });
|
|
134
|
+
Object.defineProperty(exports, "InMemoryModelCache", { enumerable: true, get: function () { return foundation_1.InMemoryModelCache; } });
|
|
135
|
+
Object.defineProperty(exports, "CacheManager", { enumerable: true, get: function () { return foundation_1.CacheManager; } });
|
|
136
136
|
var connection_utils_1 = require("./connection_utils");
|
|
137
137
|
Object.defineProperty(exports, "toAsyncGenerator", { enumerable: true, get: function () { return connection_utils_1.toAsyncGenerator; } });
|
|
138
138
|
var to_stable_1 = require("./to_stable");
|
|
@@ -146,4 +146,8 @@ Object.defineProperty(exports, "sqlKey", { enumerable: true, get: function () {
|
|
|
146
146
|
var annotation_1 = require("./annotation");
|
|
147
147
|
Object.defineProperty(exports, "annotationToTag", { enumerable: true, get: function () { return annotation_1.annotationToTag; } });
|
|
148
148
|
Object.defineProperty(exports, "annotationToTaglines", { enumerable: true, get: function () { return annotation_1.annotationToTaglines; } });
|
|
149
|
+
var foundation_2 = require("./api/foundation");
|
|
150
|
+
Object.defineProperty(exports, "PersistSource", { enumerable: true, get: function () { return foundation_2.PersistSource; } });
|
|
151
|
+
var model_2 = require("./model");
|
|
152
|
+
Object.defineProperty(exports, "makeDigest", { enumerable: true, get: function () { return model_2.makeDigest; } });
|
|
149
153
|
//# sourceMappingURL=index.js.map
|
|
@@ -26,7 +26,7 @@ exports.ErrorFactory = void 0;
|
|
|
26
26
|
const ERR_NAME = '~malformed~';
|
|
27
27
|
class ErrorFactory {
|
|
28
28
|
static get structDef() {
|
|
29
|
-
|
|
29
|
+
return {
|
|
30
30
|
type: 'table',
|
|
31
31
|
name: ERR_NAME,
|
|
32
32
|
dialect: '~malformed~',
|
|
@@ -35,10 +35,9 @@ class ErrorFactory {
|
|
|
35
35
|
fields: [],
|
|
36
36
|
errorFactory: true,
|
|
37
37
|
};
|
|
38
|
-
return factoryStruct;
|
|
39
38
|
}
|
|
40
39
|
static get joinDef() {
|
|
41
|
-
|
|
40
|
+
return {
|
|
42
41
|
type: 'table',
|
|
43
42
|
name: ERR_NAME,
|
|
44
43
|
dialect: '~malformed~',
|
|
@@ -49,10 +48,9 @@ class ErrorFactory {
|
|
|
49
48
|
matrixOperation: 'left',
|
|
50
49
|
errorFactory: true,
|
|
51
50
|
};
|
|
52
|
-
return factoryJoin;
|
|
53
51
|
}
|
|
54
52
|
static didCreate(s) {
|
|
55
|
-
return
|
|
53
|
+
return s.errorFactory === true;
|
|
56
54
|
}
|
|
57
55
|
static get query() {
|
|
58
56
|
return {
|
|
@@ -61,7 +61,13 @@ const expr_aggregate_function_1 = require("./expr-aggregate-function");
|
|
|
61
61
|
class ExprCountDistinct extends expr_aggregate_function_1.ExprAggregateFunction {
|
|
62
62
|
constructor(expr) {
|
|
63
63
|
super('distinct', expr);
|
|
64
|
-
this.legalChildTypes = [
|
|
64
|
+
this.legalChildTypes = [
|
|
65
|
+
TDU.numberT,
|
|
66
|
+
TDU.stringT,
|
|
67
|
+
TDU.dateT,
|
|
68
|
+
TDU.timestampT,
|
|
69
|
+
TDU.timestamptzT,
|
|
70
|
+
];
|
|
65
71
|
}
|
|
66
72
|
returns(ev) {
|
|
67
73
|
return {
|
|
@@ -77,7 +77,7 @@ class ExprGranularTime extends expression_def_1.ExpressionDef {
|
|
|
77
77
|
this.units = units;
|
|
78
78
|
this.truncate = truncate;
|
|
79
79
|
this.elementType = 'granularTime';
|
|
80
|
-
this.legalChildTypes = [TDU.timestampT, TDU.dateT];
|
|
80
|
+
this.legalChildTypes = [TDU.timestampT, TDU.timestamptzT, TDU.dateT];
|
|
81
81
|
}
|
|
82
82
|
granular() {
|
|
83
83
|
return true;
|
|
@@ -61,7 +61,13 @@ const expr_aggregate_function_1 = require("./expr-aggregate-function");
|
|
|
61
61
|
class ExprMax extends expr_aggregate_function_1.ExprAggregateFunction {
|
|
62
62
|
constructor(expr) {
|
|
63
63
|
super('max', expr);
|
|
64
|
-
this.legalChildTypes = [
|
|
64
|
+
this.legalChildTypes = [
|
|
65
|
+
TDU.numberT,
|
|
66
|
+
TDU.stringT,
|
|
67
|
+
TDU.dateT,
|
|
68
|
+
TDU.timestampT,
|
|
69
|
+
TDU.timestamptzT,
|
|
70
|
+
];
|
|
65
71
|
}
|
|
66
72
|
returns(ev) {
|
|
67
73
|
return ev;
|
|
@@ -61,7 +61,13 @@ const expr_aggregate_function_1 = require("./expr-aggregate-function");
|
|
|
61
61
|
class ExprMin extends expr_aggregate_function_1.ExprAggregateFunction {
|
|
62
62
|
constructor(expr) {
|
|
63
63
|
super('min', expr);
|
|
64
|
-
this.legalChildTypes = [
|
|
64
|
+
this.legalChildTypes = [
|
|
65
|
+
TDU.numberT,
|
|
66
|
+
TDU.stringT,
|
|
67
|
+
TDU.dateT,
|
|
68
|
+
TDU.timestampT,
|
|
69
|
+
TDU.timestamptzT,
|
|
70
|
+
];
|
|
65
71
|
}
|
|
66
72
|
returns(ev) {
|
|
67
73
|
return ev;
|
|
@@ -71,7 +71,7 @@ class ForRange extends expression_def_1.ExpressionDef {
|
|
|
71
71
|
this.duration = duration;
|
|
72
72
|
this.timeframe = timeframe;
|
|
73
73
|
this.elementType = 'forRange';
|
|
74
|
-
this.legalChildTypes = [TDU.timestampT, TDU.dateT];
|
|
74
|
+
this.legalChildTypes = [TDU.timestampT, TDU.timestamptzT, TDU.dateT];
|
|
75
75
|
}
|
|
76
76
|
apply(fs, op, expr) {
|
|
77
77
|
const startV = this.from.getExpression(fs);
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.QuerySource = void 0;
|
|
26
|
+
const source_def_utils_1 = require("../../../model/source_def_utils");
|
|
26
27
|
const source_1 = require("./source");
|
|
27
28
|
const uuid_1 = require("uuid");
|
|
28
29
|
class QuerySource extends source_1.Source {
|
|
@@ -37,13 +38,7 @@ class QuerySource extends source_1.Source {
|
|
|
37
38
|
withParameters(parameterSpace, pList) {
|
|
38
39
|
var _a;
|
|
39
40
|
const comp = this.query.queryComp(false);
|
|
40
|
-
const queryStruct = {
|
|
41
|
-
...comp.outputStruct,
|
|
42
|
-
name: `QuerySource-${(0, uuid_1.v4)()}`,
|
|
43
|
-
type: 'query_source',
|
|
44
|
-
query: comp.query,
|
|
45
|
-
arguments: comp.query.sourceArguments,
|
|
46
|
-
};
|
|
41
|
+
const queryStruct = (0, source_def_utils_1.mkQuerySourceDef)(comp.outputStruct, comp.query, `QuerySource-${(0, uuid_1.v4)()}`);
|
|
47
42
|
(_a = this.document()) === null || _a === void 0 ? void 0 : _a.rememberToAddModelAnnotations(queryStruct);
|
|
48
43
|
return {
|
|
49
44
|
...queryStruct,
|