@malloydata/malloy-interfaces 0.0.119-dev240124170348 → 0.0.119-dev240124192531

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/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export type { Connection, ConnectionConfig, ConnectionFactory, ConnectionParameter, ConnectionParameterValue, ConnectionConfigSchema, FetchSchemaOptions, InfoConnection, LookupConnection, ModelString, ModelURL, PersistSQLResults, PooledConnection, QueryString, QueryURL, TestableConnection, StreamingConnection, URLReader, } from './runtime_types';
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy-interfaces",
3
- "version": "0.0.119-dev240124170348",
3
+ "version": "0.0.119-dev240124192531",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,81 +0,0 @@
1
- import { DialectFragment, Expr, ExtractUnit, Sampling, StructDef, TimeFieldType, TimeValue, TimestampUnit, TypecastFragment } from '../model/malloy_types';
2
- import { DialectFunctionOverloadDef } from './functions';
3
- interface DialectField {
4
- type: string;
5
- sqlExpression: string;
6
- sqlOutputName: string;
7
- }
8
- /**
9
- * Data which dialect methods need in order to correctly generate SQL.
10
- * Initially this is just timezone related, but I made this an interface
11
- * so it would be extensible with other useful information which might not be
12
- * available until runtime (e.g. version number of db)
13
- * mtoy TODO rename this interface to something other than "QueryInfo"
14
- */
15
- export interface QueryInfo {
16
- queryTimezone?: string;
17
- systemTimezone?: string;
18
- }
19
- export declare const dayIndex: number;
20
- export declare function inDays(units: string): boolean;
21
- export declare function qtz(qi: QueryInfo): string | undefined;
22
- export type DialectFieldList = DialectField[];
23
- export declare abstract class Dialect {
24
- abstract name: string;
25
- abstract defaultNumberType: string;
26
- abstract defaultDecimalType: string;
27
- abstract udfPrefix: string;
28
- abstract hasFinalStage: boolean;
29
- abstract divisionIsInteger: boolean;
30
- abstract supportsSumDistinctFunction: boolean;
31
- abstract unnestWithNumbers: boolean;
32
- abstract defaultSampling: Sampling;
33
- abstract supportsAggDistinct: boolean;
34
- abstract supportUnnestArrayAgg: boolean;
35
- abstract supportsCTEinCoorelatedSubQueries: boolean;
36
- abstract dontUnionIndex: boolean;
37
- abstract supportsQualify: boolean;
38
- abstract supportsSafeCast: boolean;
39
- abstract supportsNesting: boolean;
40
- abstract getGlobalFunctionDef(name: string): DialectFunctionOverloadDef[] | undefined;
41
- abstract quoteTablePath(tablePath: string): string;
42
- abstract sqlGroupSetTable(groupSetCount: number): string;
43
- abstract sqlAnyValue(groupSet: number, fieldName: string): string;
44
- abstract sqlAggregateTurtle(groupSet: number, fieldList: DialectFieldList, orderBy: string | undefined, limit: number | undefined): string;
45
- abstract sqlAnyValueTurtle(groupSet: number, fieldList: DialectFieldList): string;
46
- abstract sqlAnyValueLastTurtle(name: string, groupSet: number, sqlName: string): string;
47
- abstract sqlCoaleseMeasuresInline(groupSet: number, fieldList: DialectFieldList): string;
48
- abstract sqlUnnestAlias(source: string, alias: string, fieldList: DialectFieldList, needDistinctKey: boolean, isArray: boolean, isInNestedPipeline: boolean): string;
49
- abstract sqlSumDistinctHashedKey(sqlDistinctKey: string): string;
50
- abstract sqlGenerateUUID(): string;
51
- abstract sqlFieldReference(alias: string, fieldName: string, fieldType: string, isNested: boolean, isArray: boolean): string;
52
- abstract sqlUnnestPipelineHead(isSingleton: boolean, sourceSQLExpression: string): string;
53
- abstract sqlCreateFunction(id: string, funcText: string): string;
54
- abstract sqlCreateFunctionCombineLastStage(lastStageName: string, structDef: StructDef): string;
55
- abstract sqlCreateTableAsSelect(tableName: string, sql: string): string;
56
- abstract sqlSelectAliasAsStruct(alias: string, physicalFieldNames: string[]): string;
57
- sqlFinalStage(_lastStageName: string, _fields: string[]): string;
58
- sqlDateToString(sqlDateExp: string): string;
59
- abstract sqlMaybeQuoteIdentifier(identifier: string): string;
60
- abstract sqlNow(): Expr;
61
- abstract sqlTrunc(qi: QueryInfo, sqlTime: TimeValue, units: TimestampUnit): Expr;
62
- abstract sqlExtract(qi: QueryInfo, sqlTime: TimeValue, units: ExtractUnit): Expr;
63
- abstract sqlMeasureTime(from: TimeValue, to: TimeValue, units: TimestampUnit): Expr;
64
- abstract sqlAlterTime(op: '+' | '-', expr: TimeValue, n: Expr, timeframe: TimestampUnit): Expr;
65
- ignoreInProject(_fieldName: string): boolean;
66
- abstract sqlCast(qi: QueryInfo, cast: TypecastFragment): Expr;
67
- abstract sqlLiteralTime(qi: QueryInfo, timeString: string, type: TimeFieldType, timezone?: string): string;
68
- abstract sqlLiteralString(literal: string): string;
69
- abstract sqlLiteralRegexp(literal: string): string;
70
- abstract sqlRegexpMatch(expr: Expr, regex: Expr): Expr;
71
- abstract castToString(expression: string): string;
72
- abstract concat(...values: string[]): string;
73
- sqlLiteralNumber(literal: string): string;
74
- dialectExpr(qi: QueryInfo, df: DialectFragment): Expr;
75
- sqlSumDistinct(_key: string, _value: string, _funcName: string): string;
76
- sqlAggDistinct(_key: string, _values: string[], _func: (valNames: string[]) => string): string;
77
- sqlSampleTable(tableSQL: string, sample: Sampling | undefined): string;
78
- sqlOrderBy(orderTerms: string[]): string;
79
- sqlTzStr(qi: QueryInfo): string;
80
- }
81
- export {};
@@ -1,131 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2023 Google LLC
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining
6
- * a copy of this software and associated documentation files
7
- * (the "Software"), to deal in the Software without restriction,
8
- * including without limitation the rights to use, copy, modify, merge,
9
- * publish, distribute, sublicense, and/or sell copies of the Software,
10
- * and to permit persons to whom the Software is furnished to do so,
11
- * subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be
14
- * included in all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
- */
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.Dialect = exports.qtz = exports.inDays = exports.dayIndex = void 0;
26
- const malloy_types_1 = require("../model/malloy_types");
27
- const allUnits = [
28
- 'microsecond',
29
- 'millisecond',
30
- 'second',
31
- 'minute',
32
- 'hour',
33
- 'day',
34
- 'week',
35
- 'month',
36
- 'quarter',
37
- 'year',
38
- ];
39
- exports.dayIndex = allUnits.indexOf('day');
40
- function inDays(units) {
41
- return allUnits.indexOf(units) >= exports.dayIndex;
42
- }
43
- exports.inDays = inDays;
44
- // Return the active query timezone, if it different than the
45
- // "native" timezone for timestamps.
46
- function qtz(qi) {
47
- const tz = qi.queryTimezone;
48
- if (tz === undefined || tz === qi.systemTimezone) {
49
- return undefined;
50
- }
51
- return tz;
52
- }
53
- exports.qtz = qtz;
54
- class Dialect {
55
- sqlFinalStage(_lastStageName, _fields) {
56
- throw new Error('Dialect has no final Stage but called Anyway');
57
- }
58
- // default implementation will probably work most of the time
59
- sqlDateToString(sqlDateExp) {
60
- return this.castToString(`DATE(${sqlDateExp})`);
61
- }
62
- // BigQuery has some fieldNames that are Pseudo Fields and shouldn't be
63
- // included in projections.
64
- ignoreInProject(_fieldName) {
65
- return false;
66
- }
67
- sqlLiteralNumber(literal) {
68
- return literal;
69
- }
70
- dialectExpr(qi, df) {
71
- switch (df.function) {
72
- case 'now':
73
- return this.sqlNow();
74
- case 'timeDiff':
75
- return this.sqlMeasureTime(df.left, df.right, df.units);
76
- case 'delta':
77
- return this.sqlAlterTime(df.op, df.base, df.delta, df.units);
78
- case 'trunc':
79
- return this.sqlTrunc(qi, df.expr, df.units);
80
- case 'extract':
81
- return this.sqlExtract(qi, df.expr, df.units);
82
- case 'cast':
83
- return this.sqlCast(qi, df);
84
- case 'regexpMatch':
85
- return this.sqlRegexpMatch(df.expr, df.regexp);
86
- case 'div': {
87
- if (this.divisionIsInteger) {
88
- return (0, malloy_types_1.mkExpr) `${df.numerator}*1.0/${df.denominator}`;
89
- }
90
- return (0, malloy_types_1.mkExpr) `${df.numerator}/${df.denominator}`;
91
- }
92
- case 'timeLiteral': {
93
- return [
94
- this.sqlLiteralTime(qi, df.literal, df.literalType, df.timezone),
95
- ];
96
- }
97
- case 'stringLiteral':
98
- return [this.sqlLiteralString(df.literal)];
99
- case 'numberLiteral':
100
- return [this.sqlLiteralNumber(df.literal)];
101
- case 'regexpLiteral':
102
- return [this.sqlLiteralRegexp(df.literal)];
103
- }
104
- }
105
- sqlSumDistinct(_key, _value, _funcName) {
106
- return 'sqlSumDistinct called but not implemented';
107
- }
108
- // Like sqlSumDistinct, but for an arbitrary aggregate expression
109
- sqlAggDistinct(_key, _values,
110
- // A function which takes the value names used internally and produces the SQL operation using those
111
- // value names.
112
- // TODO maybe this should be flipped around and the SQL should be passed in directly along with the
113
- // value names used?
114
- _func) {
115
- return 'sqlAggDistinct called but not implemented';
116
- }
117
- sqlSampleTable(tableSQL, sample) {
118
- if (sample !== undefined) {
119
- throw new Error(`Sampling is not supported on dialect ${this.name}.`);
120
- }
121
- return tableSQL;
122
- }
123
- sqlOrderBy(orderTerms) {
124
- return `ORDER BY ${orderTerms.join(',')}`;
125
- }
126
- sqlTzStr(qi) {
127
- return `"${qi.queryTimezone}"`;
128
- }
129
- }
130
- exports.Dialect = Dialect;
131
- //# sourceMappingURL=dialect.js.map
@@ -1,11 +0,0 @@
1
- import { Expr, FunctionParameterDef, TypeDesc } from '../../model';
2
- export interface DialectFunctionOverloadDef {
3
- returnType: TypeDesc;
4
- params: FunctionParameterDef[];
5
- e: Expr;
6
- needsWindowOrderBy?: boolean;
7
- between: {
8
- preceding: number | string;
9
- following: number | string;
10
- } | undefined;
11
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- export { Dialect } from './dialect';
@@ -1,28 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2023 Google LLC
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining
6
- * a copy of this software and associated documentation files
7
- * (the "Software"), to deal in the Software without restriction,
8
- * including without limitation the rights to use, copy, modify, merge,
9
- * publish, distribute, sublicense, and/or sell copies of the Software,
10
- * and to permit persons to whom the Software is furnished to do so,
11
- * subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be
14
- * included in all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
- */
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.Dialect = void 0;
26
- var dialect_1 = require("./dialect");
27
- Object.defineProperty(exports, "Dialect", { enumerable: true, get: function () { return dialect_1.Dialect; } });
28
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- export * from './malloy_types';
@@ -1,40 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2023 Google LLC
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining
6
- * a copy of this software and associated documentation files
7
- * (the "Software"), to deal in the Software without restriction,
8
- * including without limitation the rights to use, copy, modify, merge,
9
- * publish, distribute, sublicense, and/or sell copies of the Software,
10
- * and to permit persons to whom the Software is furnished to do so,
11
- * subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be
14
- * included in all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
- */
24
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- var desc = Object.getOwnPropertyDescriptor(m, k);
27
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28
- desc = { enumerable: true, get: function() { return m[k]; } };
29
- }
30
- Object.defineProperty(o, k2, desc);
31
- }) : (function(o, m, k, k2) {
32
- if (k2 === undefined) k2 = k;
33
- o[k2] = m[k];
34
- }));
35
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- __exportStar(require("./malloy_types"), exports);
40
- //# sourceMappingURL=index.js.map