@malloydata/malloy 0.0.350 → 0.0.352
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/annotation.js +6 -6
- package/dist/dialect/databricks/databricks.d.ts +94 -0
- package/dist/dialect/databricks/databricks.js +441 -0
- package/dist/dialect/databricks/dialect_functions.d.ts +2 -0
- package/dist/dialect/databricks/dialect_functions.js +67 -0
- package/dist/dialect/databricks/function_overrides.d.ts +2 -0
- package/dist/dialect/databricks/function_overrides.js +68 -0
- package/dist/dialect/databricks/index.d.ts +1 -0
- package/dist/dialect/databricks/index.js +22 -0
- package/dist/dialect/dialect.d.ts +24 -1
- package/dist/dialect/dialect.js +31 -1
- package/dist/dialect/dialect_map.js +2 -0
- package/dist/dialect/duckdb/duckdb.d.ts +2 -2
- package/dist/dialect/duckdb/duckdb.js +2 -1
- package/dist/dialect/index.d.ts +2 -1
- package/dist/dialect/index.js +3 -1
- package/dist/dialect/mysql/mysql.d.ts +2 -2
- package/dist/dialect/mysql/mysql.js +3 -2
- package/dist/dialect/postgres/postgres.d.ts +2 -2
- package/dist/dialect/postgres/postgres.js +3 -1
- package/dist/dialect/snowflake/snowflake.d.ts +2 -2
- package/dist/dialect/snowflake/snowflake.js +3 -1
- package/dist/dialect/standardsql/standardsql.d.ts +4 -3
- package/dist/dialect/standardsql/standardsql.js +6 -1
- package/dist/dialect/trino/trino.d.ts +2 -2
- package/dist/dialect/trino/trino.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/lang/ast/query-elements/query-base.d.ts +1 -1
- package/dist/lang/ast/query-elements/query-base.js +2 -2
- package/dist/lang/ast/query-elements/query-raw.d.ts +1 -1
- package/dist/lang/ast/query-elements/query-raw.js +2 -2
- package/dist/lang/ast/query-elements/query-reference.d.ts +1 -1
- package/dist/lang/ast/query-elements/query-reference.js +2 -2
- package/dist/lang/ast/sql-elements/sql-string.js +1 -1
- package/dist/lang/ast/types/query-element.d.ts +1 -1
- package/dist/lang/lib/Malloy/MalloyLexer.js +1 -1
- package/dist/lang/lib/Malloy/MalloyParser.js +1 -1
- package/dist/lang/lib/Malloy/MalloyParserListener.js +1 -1
- package/dist/lang/lib/Malloy/MalloyParserVisitor.js +1 -1
- package/dist/model/query_query.d.ts +2 -2
- package/dist/model/query_query.js +57 -19
- package/dist/test/resultMatchers.d.ts +5 -3
- package/dist/test/resultMatchers.js +160 -150
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/femto-config.motly +21 -0
- package/package.json +8 -6
|
@@ -0,0 +1,68 @@
|
|
|
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.DATABRICKS_MALLOY_STANDARD_OVERLOADS = void 0;
|
|
8
|
+
// Template strings use ${...values} for Malloy parameter interpolation.
|
|
9
|
+
// The ELSE branch uses a JS template literal to inject `name`, so the
|
|
10
|
+
// Malloy parameter reference must be escaped as \${...values}.
|
|
11
|
+
function greatestOrLeastSQL(name) {
|
|
12
|
+
return ('CASE' +
|
|
13
|
+
' WHEN SIZE(FILTER(ARRAY(${...values}), x -> x IS NULL)) > 0' +
|
|
14
|
+
' THEN NULL' +
|
|
15
|
+
` ELSE ${name}(\${...values})` +
|
|
16
|
+
' END');
|
|
17
|
+
}
|
|
18
|
+
exports.DATABRICKS_MALLOY_STANDARD_OVERLOADS = {
|
|
19
|
+
// Databricks REGEXP_EXTRACT defaults to group index 1 (first capture group),
|
|
20
|
+
// but Malloy expects the full match (group 0). Explicitly pass idx=0.
|
|
21
|
+
regexp_extract: { sql: 'REGEXP_EXTRACT(${value}, ${pattern}, 0)' },
|
|
22
|
+
replace: {
|
|
23
|
+
regular_expression: {
|
|
24
|
+
sql: 'REGEXP_REPLACE(${value}, ${pattern}, ${replacement})',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
trunc: {
|
|
28
|
+
to_integer: {
|
|
29
|
+
sql: 'CAST(${value} AS BIGINT)',
|
|
30
|
+
},
|
|
31
|
+
to_precision: {
|
|
32
|
+
sql: '(ABS(FLOOR(${value} * POW(10,${precision}))/POW(10,${precision}))*IF(${value} < 0, -1, 1))',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
log: { sql: 'LOG(${base},${value})' },
|
|
36
|
+
div: { sql: 'FLOOR(${dividend} / ${divisor})' },
|
|
37
|
+
strpos: { sql: 'LOCATE(${search_string},${test_string})' },
|
|
38
|
+
starts_with: { sql: 'COALESCE(STARTSWITH(${value},${prefix}), false)' },
|
|
39
|
+
ends_with: { sql: 'COALESCE(ENDSWITH(${value},${suffix}), false)' },
|
|
40
|
+
trim: {
|
|
41
|
+
characters: {
|
|
42
|
+
sql: 'TRIM(BOTH ${trim_characters} FROM ${value})',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
ltrim: {
|
|
46
|
+
characters: {
|
|
47
|
+
sql: 'TRIM(LEADING ${trim_characters} FROM ${value})',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
rtrim: {
|
|
51
|
+
characters: {
|
|
52
|
+
sql: 'TRIM(TRAILING ${trim_characters} FROM ${value})',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
byte_length: { sql: 'OCTET_LENGTH(${value})' },
|
|
56
|
+
chr: { sql: 'CHR(${value})' },
|
|
57
|
+
// Databricks has no IS_INF/IS_NAN functions; compare to special float values
|
|
58
|
+
is_inf: {
|
|
59
|
+
sql: "COALESCE(${value} = DOUBLE('infinity') OR ${value} = DOUBLE('-infinity'), false)",
|
|
60
|
+
},
|
|
61
|
+
is_nan: { sql: "COALESCE(${value} = DOUBLE('NaN'), false)" },
|
|
62
|
+
// Databricks ASCII() returns the Unicode codepoint of the first character
|
|
63
|
+
unicode: { function: 'ASCII' },
|
|
64
|
+
// Databricks GREATEST/LEAST skip nulls; Malloy expects null propagation
|
|
65
|
+
greatest: { sql: greatestOrLeastSQL('GREATEST') },
|
|
66
|
+
least: { sql: greatestOrLeastSQL('LEAST') },
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=function_overrides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './databricks';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Contributors to the Malloy project
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
__exportStar(require("./databricks"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -7,6 +7,26 @@ interface DialectField {
|
|
|
7
7
|
sqlOutputName: string;
|
|
8
8
|
}
|
|
9
9
|
export type DialectFieldList = DialectField[];
|
|
10
|
+
/**
|
|
11
|
+
* Order-by entry with field references resolved to SQL expressions
|
|
12
|
+
* and direction defaulted. Used by sqlAggregateTurtle so each dialect
|
|
13
|
+
* can format ordering in its own syntax.
|
|
14
|
+
*/
|
|
15
|
+
export interface CompiledOrderBy {
|
|
16
|
+
/** SQL expression for the ordering column (e.g. the group_set-suffixed CTE column name) */
|
|
17
|
+
field: string;
|
|
18
|
+
/** The struct output field name, for dialects that sort via struct field reference */
|
|
19
|
+
structField: string;
|
|
20
|
+
dir: 'asc' | 'desc';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A named expression for the lateral join bag. The expression will be
|
|
24
|
+
* available as `__lateral_join_bag.name` in the query.
|
|
25
|
+
*/
|
|
26
|
+
export interface LateralJoinExpression {
|
|
27
|
+
sql: string;
|
|
28
|
+
name: string;
|
|
29
|
+
}
|
|
10
30
|
export declare const MIN_INT32 = -2147483648;
|
|
11
31
|
export declare const MAX_INT32 = 2147483647;
|
|
12
32
|
export declare const MIN_INT64: bigint;
|
|
@@ -64,6 +84,7 @@ export declare abstract class Dialect {
|
|
|
64
84
|
abstract supportsNesting: boolean;
|
|
65
85
|
abstract experimental: boolean;
|
|
66
86
|
cantPartitionWindowFunctionsOnExpressions: boolean;
|
|
87
|
+
sqlLateralJoinBag(_expressions: LateralJoinExpression[]): string;
|
|
67
88
|
supportsPipelinesInViews: boolean;
|
|
68
89
|
supportsArraysInData: boolean;
|
|
69
90
|
hasTimestamptz: boolean;
|
|
@@ -78,6 +99,7 @@ export declare abstract class Dialect {
|
|
|
78
99
|
hasModOperator: boolean;
|
|
79
100
|
supportsLeftJoinUnnest: boolean;
|
|
80
101
|
requiresExplicitUnnestOrdering: boolean;
|
|
102
|
+
hasLateralColumnAliasInSelect: boolean;
|
|
81
103
|
supportsCountApprox: boolean;
|
|
82
104
|
supportsHyperLogLog: boolean;
|
|
83
105
|
supportsFullJoin: boolean;
|
|
@@ -113,7 +135,8 @@ export declare abstract class Dialect {
|
|
|
113
135
|
abstract quoteTablePath(tablePath: string): string;
|
|
114
136
|
abstract sqlGroupSetTable(groupSetCount: number): string;
|
|
115
137
|
abstract sqlAnyValue(groupSet: number, fieldName: string): string;
|
|
116
|
-
abstract sqlAggregateTurtle(groupSet: number, fieldList: DialectFieldList, orderBy:
|
|
138
|
+
abstract sqlAggregateTurtle(groupSet: number, fieldList: DialectFieldList, orderBy: CompiledOrderBy[] | undefined): string;
|
|
139
|
+
sqlTurtleOrderByClause(orderBy: CompiledOrderBy[]): string;
|
|
117
140
|
abstract sqlAnyValueTurtle(groupSet: number, fieldList: DialectFieldList): string;
|
|
118
141
|
abstract sqlAnyValueLastTurtle(name: string, groupSet: number, sqlName: string): string;
|
|
119
142
|
abstract sqlCoaleseMeasuresInline(groupSet: number, fieldList: DialectFieldList): string;
|
package/dist/dialect/dialect.js
CHANGED
|
@@ -72,7 +72,10 @@ class Dialect {
|
|
|
72
72
|
// -- we should add flags with default values from now on so as to not break
|
|
73
73
|
// dialects outside our repository
|
|
74
74
|
//
|
|
75
|
-
// StandardSQL dialects can't partition on expression in window functions
|
|
75
|
+
// StandardSQL dialects can't partition on expression in window functions.
|
|
76
|
+
// When true, dimension expressions used in PARTITION BY are moved to a
|
|
77
|
+
// lateral join bag so the PARTITION BY can reference a column name instead
|
|
78
|
+
// of a raw expression. See sqlLateralJoinBag for dialect-specific syntax.
|
|
76
79
|
this.cantPartitionWindowFunctionsOnExpressions = false;
|
|
77
80
|
// Snowflake can't yet support pipelines in nested views.
|
|
78
81
|
this.supportsPipelinesInViews = true;
|
|
@@ -104,6 +107,16 @@ class Dialect {
|
|
|
104
107
|
// UNNEST in LATERAL JOINs doesn't guarantee array element order.
|
|
105
108
|
// When true, compiler adds ORDER BY on array ordinality columns (__row_id)
|
|
106
109
|
this.requiresExplicitUnnestOrdering = false;
|
|
110
|
+
// In most SQL dialects, column aliases defined in a SELECT clause are not
|
|
111
|
+
// visible to other expressions in the same SELECT. However, some dialects
|
|
112
|
+
// (e.g. Databricks/Spark) support "lateral column aliases", where an alias
|
|
113
|
+
// can be referenced by later expressions in the same SELECT. This causes
|
|
114
|
+
// problems when the compiler remaps the `group_set` column in a combine-
|
|
115
|
+
// turtles stage: the alias shadows the input column, so CASE WHEN
|
|
116
|
+
// group_set=N checks in aggregate expressions see the remapped value
|
|
117
|
+
// instead of the original. When true, the compiler splits the group_set
|
|
118
|
+
// remapping into a separate CTE to avoid shadowing.
|
|
119
|
+
this.hasLateralColumnAliasInSelect = false;
|
|
107
120
|
this.supportsCountApprox = false;
|
|
108
121
|
this.supportsHyperLogLog = false;
|
|
109
122
|
// MYSQL doesn't have full join, maybe others.
|
|
@@ -126,6 +139,16 @@ class Dialect {
|
|
|
126
139
|
{ min: exports.MIN_INT64, max: exports.MAX_INT64, numberType: 'bigint' },
|
|
127
140
|
];
|
|
128
141
|
}
|
|
142
|
+
// Generate the lateral join bag clause for window function partitioning.
|
|
143
|
+
// The expressions are dimension fields that need to be referenced by name
|
|
144
|
+
// in PARTITION BY clauses. Must be overridden by any dialect that sets
|
|
145
|
+
// cantPartitionWindowFunctionsOnExpressions = true.
|
|
146
|
+
sqlLateralJoinBag(_expressions) {
|
|
147
|
+
if (this.cantPartitionWindowFunctionsOnExpressions) {
|
|
148
|
+
throw new Error(`Dialect '${this.name}' sets cantPartitionWindowFunctionsOnExpressions but does not implement sqlLateralJoinBag`);
|
|
149
|
+
}
|
|
150
|
+
throw new Error('Internal error: sqlLateralJoinBag called but cantPartitionWindowFunctionsOnExpressions is false');
|
|
151
|
+
}
|
|
129
152
|
/**
|
|
130
153
|
* Determine the Malloy number type for a numeric literal.
|
|
131
154
|
*/
|
|
@@ -195,6 +218,13 @@ class Dialect {
|
|
|
195
218
|
},
|
|
196
219
|
};
|
|
197
220
|
}
|
|
221
|
+
// Format a CompiledOrderBy[] into an ORDER BY clause string for use
|
|
222
|
+
// inside an aggregate turtle expression. Dialects which support ORDER BY
|
|
223
|
+
// inside aggregate functions can call this helper from sqlAggregateTurtle.
|
|
224
|
+
sqlTurtleOrderByClause(orderBy) {
|
|
225
|
+
const terms = orderBy.map(o => ` ${o.field} ${o.dir.toUpperCase()}`);
|
|
226
|
+
return ' ' + this.sqlOrderBy(terms, 'turtle');
|
|
227
|
+
}
|
|
198
228
|
sqlFinalStage(_lastStageName, _fields) {
|
|
199
229
|
throw new Error('Dialect has no final Stage but called Anyway');
|
|
200
230
|
}
|
|
@@ -31,6 +31,7 @@ const snowflake_1 = require("./snowflake");
|
|
|
31
31
|
const standardsql_1 = require("./standardsql");
|
|
32
32
|
const trino_1 = require("./trino");
|
|
33
33
|
const mysql_1 = require("./mysql");
|
|
34
|
+
const databricks_1 = require("./databricks");
|
|
34
35
|
const dialectMap = new Map();
|
|
35
36
|
function getDialect(name) {
|
|
36
37
|
const d = dialectMap.get(name);
|
|
@@ -52,4 +53,5 @@ registerDialect(new snowflake_1.SnowflakeDialect());
|
|
|
52
53
|
registerDialect(new trino_1.TrinoDialect());
|
|
53
54
|
registerDialect(new trino_1.PrestoDialect());
|
|
54
55
|
registerDialect(new mysql_1.MySQLDialect());
|
|
56
|
+
registerDialect(new databricks_1.DatabricksDialect());
|
|
55
57
|
//# sourceMappingURL=dialect_map.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Sampling, AtomicTypeDef, RegexMatchExpr, MeasureTimeExpr, BasicAtomicTypeDef, RecordLiteralNode, OrderBy, TimestampUnit } from '../../model/malloy_types';
|
|
2
2
|
import type { DialectFunctionOverloadDef } from '../functions';
|
|
3
|
-
import type { DialectFieldList, FieldReferenceType, IntegerTypeMapping } from '../dialect';
|
|
3
|
+
import type { CompiledOrderBy, DialectFieldList, FieldReferenceType, IntegerTypeMapping } from '../dialect';
|
|
4
4
|
import { PostgresBase } from '../pg_impl';
|
|
5
5
|
export declare class DuckDBDialect extends PostgresBase {
|
|
6
6
|
name: string;
|
|
@@ -30,7 +30,7 @@ export declare class DuckDBDialect extends PostgresBase {
|
|
|
30
30
|
sqlAnyValue(groupSet: number, fieldName: string): string;
|
|
31
31
|
sqlLiteralNumber(literal: string): string;
|
|
32
32
|
mapFields(fieldList: DialectFieldList): string;
|
|
33
|
-
sqlAggregateTurtle(groupSet: number, fieldList: DialectFieldList, orderBy:
|
|
33
|
+
sqlAggregateTurtle(groupSet: number, fieldList: DialectFieldList, orderBy: CompiledOrderBy[] | undefined): string;
|
|
34
34
|
sqlAnyValueTurtle(groupSet: number, fieldList: DialectFieldList): string;
|
|
35
35
|
sqlAnyValueLastTurtle(name: string, groupSet: number, sqlName: string): string;
|
|
36
36
|
sqlCoaleseMeasuresInline(groupSet: number, fieldList: DialectFieldList): string;
|
|
@@ -109,7 +109,8 @@ class DuckDBDialect extends pg_impl_1.PostgresBase {
|
|
|
109
109
|
const fields = fieldList
|
|
110
110
|
.map(f => `\n ${f.sqlOutputName}: ${f.sqlExpression}`)
|
|
111
111
|
.join(', ');
|
|
112
|
-
|
|
112
|
+
const orderByClause = orderBy ? this.sqlTurtleOrderByClause(orderBy) : '';
|
|
113
|
+
return `COALESCE(LIST({${fields}} ${orderByClause}) FILTER (WHERE group_set=${groupSet}),[])`;
|
|
113
114
|
}
|
|
114
115
|
sqlAnyValueTurtle(groupSet, fieldList) {
|
|
115
116
|
const fields = fieldList
|
package/dist/dialect/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export type { DialectFunctionOverloadDef, DefinitionBlueprint, DefinitionBlueprintMap, OverloadedDefinitionBlueprint, } from './functions/util';
|
|
2
2
|
export { arg, anyExprType, makeParam, overload, minScalar, minAggregate, maxScalar, spread, param, variadicParam, literal, sql, } from './functions/util';
|
|
3
3
|
export { Dialect, qtz } from './dialect';
|
|
4
|
-
export type { DialectFieldList, QueryInfo, FieldReferenceType } from './dialect';
|
|
4
|
+
export type { DialectFieldList, CompiledOrderBy, LateralJoinExpression, QueryInfo, FieldReferenceType, } from './dialect';
|
|
5
5
|
export { StandardSQLDialect } from './standardsql';
|
|
6
6
|
export { PostgresDialect } from './postgres';
|
|
7
7
|
export { DuckDBDialect } from './duckdb';
|
|
8
8
|
export { SnowflakeDialect } from './snowflake';
|
|
9
9
|
export { TrinoDialect } from './trino';
|
|
10
10
|
export { MySQLDialect } from './mysql';
|
|
11
|
+
export { DatabricksDialect } from './databricks';
|
|
11
12
|
export { getDialect, registerDialect } from './dialect_map';
|
|
12
13
|
export { getMalloyStandardFunctions } from './functions';
|
|
13
14
|
export type { MalloyStandardFunctionImplementations } from './functions';
|
package/dist/dialect/index.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.TinyParser = exports.getMalloyStandardFunctions = exports.registerDialect = exports.getDialect = exports.MySQLDialect = exports.TrinoDialect = exports.SnowflakeDialect = exports.DuckDBDialect = exports.PostgresDialect = exports.StandardSQLDialect = exports.qtz = exports.Dialect = exports.sql = exports.literal = exports.variadicParam = exports.param = exports.spread = exports.maxScalar = exports.minAggregate = exports.minScalar = exports.overload = exports.makeParam = exports.anyExprType = exports.arg = void 0;
|
|
25
|
+
exports.TinyParser = exports.getMalloyStandardFunctions = exports.registerDialect = exports.getDialect = exports.DatabricksDialect = exports.MySQLDialect = exports.TrinoDialect = exports.SnowflakeDialect = exports.DuckDBDialect = exports.PostgresDialect = exports.StandardSQLDialect = exports.qtz = exports.Dialect = exports.sql = exports.literal = exports.variadicParam = exports.param = exports.spread = exports.maxScalar = exports.minAggregate = exports.minScalar = exports.overload = exports.makeParam = exports.anyExprType = exports.arg = void 0;
|
|
26
26
|
var util_1 = require("./functions/util");
|
|
27
27
|
Object.defineProperty(exports, "arg", { enumerable: true, get: function () { return util_1.arg; } });
|
|
28
28
|
Object.defineProperty(exports, "anyExprType", { enumerable: true, get: function () { return util_1.anyExprType; } });
|
|
@@ -51,6 +51,8 @@ var trino_1 = require("./trino");
|
|
|
51
51
|
Object.defineProperty(exports, "TrinoDialect", { enumerable: true, get: function () { return trino_1.TrinoDialect; } });
|
|
52
52
|
var mysql_1 = require("./mysql");
|
|
53
53
|
Object.defineProperty(exports, "MySQLDialect", { enumerable: true, get: function () { return mysql_1.MySQLDialect; } });
|
|
54
|
+
var databricks_1 = require("./databricks");
|
|
55
|
+
Object.defineProperty(exports, "DatabricksDialect", { enumerable: true, get: function () { return databricks_1.DatabricksDialect; } });
|
|
54
56
|
var dialect_map_1 = require("./dialect_map");
|
|
55
57
|
Object.defineProperty(exports, "getDialect", { enumerable: true, get: function () { return dialect_map_1.getDialect; } });
|
|
56
58
|
Object.defineProperty(exports, "registerDialect", { enumerable: true, get: function () { return dialect_map_1.registerDialect; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Sampling, MeasureTimeExpr, RegexMatchExpr, TimeExtractExpr, TypecastExpr, BasicAtomicTypeDef, AtomicTypeDef, TimestampTypeDef, ArrayLiteralNode, RecordLiteralNode } from '../../model/malloy_types';
|
|
2
|
-
import type { BooleanTypeSupport, DialectFieldList, FieldReferenceType, OrderByClauseType, QueryInfo } from '../dialect';
|
|
2
|
+
import type { BooleanTypeSupport, CompiledOrderBy, DialectFieldList, FieldReferenceType, OrderByClauseType, QueryInfo } from '../dialect';
|
|
3
3
|
import { Dialect } from '../dialect';
|
|
4
4
|
import type { DialectFunctionOverloadDef } from '../functions';
|
|
5
5
|
export declare class MySQLDialect extends Dialect {
|
|
@@ -38,7 +38,7 @@ export declare class MySQLDialect extends Dialect {
|
|
|
38
38
|
sqlGroupSetTable(groupSetCount: number): string;
|
|
39
39
|
sqlAnyValue(_groupSet: number, fieldName: string): string;
|
|
40
40
|
private mapFields;
|
|
41
|
-
sqlAggregateTurtle(groupSet: number, fieldList: DialectFieldList, orderBy:
|
|
41
|
+
sqlAggregateTurtle(groupSet: number, fieldList: DialectFieldList, orderBy: CompiledOrderBy[] | undefined): string;
|
|
42
42
|
sqlAnyValueTurtle(groupSet: number, fieldList: DialectFieldList): string;
|
|
43
43
|
sqlAnyValueLastTurtle(name: string, groupSet: number, sqlName: string): string;
|
|
44
44
|
sqlCoaleseMeasuresInline(groupSet: number, fieldList: DialectFieldList): string;
|
|
@@ -105,7 +105,7 @@ class MySQLDialect extends dialect_1.Dialect {
|
|
|
105
105
|
this.unnestWithNumbers = false;
|
|
106
106
|
this.defaultSampling = { rows: 50000 };
|
|
107
107
|
this.supportUnnestArrayAgg = true;
|
|
108
|
-
this.supportsAggDistinct =
|
|
108
|
+
this.supportsAggDistinct = false;
|
|
109
109
|
this.supportsCTEinCoorelatedSubQueries = true;
|
|
110
110
|
this.supportsSafeCast = false;
|
|
111
111
|
this.dontUnionIndex = false;
|
|
@@ -171,12 +171,13 @@ class MySQLDialect extends dialect_1.Dialect {
|
|
|
171
171
|
}
|
|
172
172
|
sqlAggregateTurtle(groupSet, fieldList, orderBy) {
|
|
173
173
|
const separator = ',';
|
|
174
|
+
const orderByClause = orderBy ? this.sqlTurtleOrderByClause(orderBy) : '';
|
|
174
175
|
let gc = `GROUP_CONCAT(
|
|
175
176
|
IF(group_set=${groupSet},
|
|
176
177
|
JSON_OBJECT(${this.mapFields(fieldList)})
|
|
177
178
|
, null
|
|
178
179
|
)
|
|
179
|
-
${
|
|
180
|
+
${orderByClause}
|
|
180
181
|
SEPARATOR '${separator}'
|
|
181
182
|
)`;
|
|
182
183
|
gc = `COALESCE(JSON_EXTRACT(CONCAT('[',${gc},']'),'$'),JSON_ARRAY())`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Sampling, AtomicTypeDef, TypecastExpr, MeasureTimeExpr, BasicAtomicTypeDef, RecordLiteralNode, ArrayLiteralNode, TimeExtractExpr, TimestampUnit } from '../../model/malloy_types';
|
|
2
2
|
import type { DialectFunctionOverloadDef } from '../functions';
|
|
3
|
-
import { type DialectFieldList, type FieldReferenceType, type QueryInfo } from '../dialect';
|
|
3
|
+
import { type CompiledOrderBy, type DialectFieldList, type FieldReferenceType, type QueryInfo } from '../dialect';
|
|
4
4
|
import { PostgresBase } from '../pg_impl';
|
|
5
5
|
export declare class PostgresDialect extends PostgresBase {
|
|
6
6
|
name: string;
|
|
@@ -31,7 +31,7 @@ export declare class PostgresDialect extends PostgresBase {
|
|
|
31
31
|
sqlGroupSetTable(groupSetCount: number): string;
|
|
32
32
|
sqlAnyValue(groupSet: number, fieldName: string): string;
|
|
33
33
|
mapFields(fieldList: DialectFieldList): string;
|
|
34
|
-
sqlAggregateTurtle(groupSet: number, fieldList: DialectFieldList, orderBy:
|
|
34
|
+
sqlAggregateTurtle(groupSet: number, fieldList: DialectFieldList, orderBy: CompiledOrderBy[] | undefined): string;
|
|
35
35
|
sqlAnyValueTurtle(groupSet: number, fieldList: DialectFieldList): string;
|
|
36
36
|
sqlAnyValueLastTurtle(name: string, groupSet: number, sqlName: string): string;
|
|
37
37
|
sqlCoaleseMeasuresInline(groupSet: number, fieldList: DialectFieldList): string;
|
|
@@ -57,6 +57,7 @@ const postgresToMalloyTypes = {
|
|
|
57
57
|
'double precision': { type: 'number', numberType: 'float' },
|
|
58
58
|
'timestamp without time zone': { type: 'timestamp' },
|
|
59
59
|
'timestamp with time zone': { type: 'timestamptz' },
|
|
60
|
+
'timestamptz': { type: 'timestamptz' },
|
|
60
61
|
'oid': { type: 'string' },
|
|
61
62
|
'boolean': { type: 'boolean' },
|
|
62
63
|
'timestamp': { type: 'timestamp' },
|
|
@@ -118,7 +119,8 @@ class PostgresDialect extends pg_impl_1.PostgresBase {
|
|
|
118
119
|
}
|
|
119
120
|
sqlAggregateTurtle(groupSet, fieldList, orderBy) {
|
|
120
121
|
const fields = this.mapFields(fieldList);
|
|
121
|
-
|
|
122
|
+
const orderByClause = orderBy ? this.sqlTurtleOrderByClause(orderBy) : '';
|
|
123
|
+
return `COALESCE(TO_JSONB((ARRAY_AGG((SELECT TO_JSONB(__x) FROM (SELECT ${fields}\n ) as __x) ${orderByClause} ) FILTER (WHERE group_set=${groupSet}))),'[]'::JSONB)`;
|
|
122
124
|
}
|
|
123
125
|
sqlAnyValueTurtle(groupSet, fieldList) {
|
|
124
126
|
const fields = fieldList
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Sampling, AtomicTypeDef, TimeExtractExpr, TypecastExpr, MeasureTimeExpr, RegexMatchExpr, BasicAtomicTypeDef, TimestampTypeDef, ArrayLiteralNode, RecordLiteralNode } from '../../model/malloy_types';
|
|
2
2
|
import type { DialectFunctionOverloadDef } from '../functions';
|
|
3
|
-
import type { DialectFieldList, FieldReferenceType, IntegerTypeMapping, QueryInfo } from '../dialect';
|
|
3
|
+
import type { CompiledOrderBy, DialectFieldList, FieldReferenceType, IntegerTypeMapping, QueryInfo } from '../dialect';
|
|
4
4
|
import { Dialect } from '../dialect';
|
|
5
5
|
export declare class SnowflakeDialect extends Dialect {
|
|
6
6
|
name: string;
|
|
@@ -32,7 +32,7 @@ export declare class SnowflakeDialect extends Dialect {
|
|
|
32
32
|
sqlAnyValue(groupSet: number, fieldName: string): string;
|
|
33
33
|
mapFields(fieldList: DialectFieldList): string;
|
|
34
34
|
mapFieldsForObjectConstruct(fieldList: DialectFieldList): string;
|
|
35
|
-
sqlAggregateTurtle(groupSet: number, fieldList: DialectFieldList, orderBy:
|
|
35
|
+
sqlAggregateTurtle(groupSet: number, fieldList: DialectFieldList, orderBy: CompiledOrderBy[] | undefined): string;
|
|
36
36
|
sqlAnyValueTurtle(groupSet: number, fieldList: DialectFieldList): string;
|
|
37
37
|
sqlAnyValueLastTurtle(name: string, groupSet: number, sqlName: string): string;
|
|
38
38
|
sqlCoaleseMeasuresInline(groupSet: number, fieldList: DialectFieldList): string;
|
|
@@ -131,7 +131,9 @@ class SnowflakeDialect extends dialect_1.Dialect {
|
|
|
131
131
|
}
|
|
132
132
|
sqlAggregateTurtle(groupSet, fieldList, orderBy) {
|
|
133
133
|
const fields = this.mapFieldsForObjectConstruct(fieldList);
|
|
134
|
-
const orderByClause = orderBy
|
|
134
|
+
const orderByClause = orderBy
|
|
135
|
+
? ` WITHIN GROUP (${this.sqlTurtleOrderByClause(orderBy)})`
|
|
136
|
+
: '';
|
|
135
137
|
const aggClause = `ARRAY_AGG(CASE WHEN group_set=${groupSet} THEN OBJECT_CONSTRUCT_KEEP_NULL(${fields}) END)${orderByClause}`;
|
|
136
138
|
return `COALESCE(${aggClause}, [])`;
|
|
137
139
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Sampling, AtomicTypeDef, TimeExtractExpr, TypecastExpr, RegexMatchExpr, MeasureTimeExpr, BasicAtomicTypeDef, RecordLiteralNode, ArrayLiteralNode, TimestampUnit, TimestampTypeDef } from '../../model/malloy_types';
|
|
2
2
|
import type { DialectFunctionOverloadDef } from '../functions';
|
|
3
|
-
import type { DialectFieldList, IntegerTypeMapping, OrderByRequest, QueryInfo } from '../dialect';
|
|
4
|
-
import { Dialect } from '../dialect';
|
|
3
|
+
import type { CompiledOrderBy, DialectFieldList, IntegerTypeMapping, OrderByRequest, QueryInfo } from '../dialect';
|
|
4
|
+
import { Dialect, type LateralJoinExpression } from '../dialect';
|
|
5
5
|
export declare class StandardSQLDialect extends Dialect {
|
|
6
6
|
name: string;
|
|
7
7
|
experimental: boolean;
|
|
@@ -24,6 +24,7 @@ export declare class StandardSQLDialect extends Dialect {
|
|
|
24
24
|
supportsNesting: boolean;
|
|
25
25
|
cantPartitionWindowFunctionsOnExpressions: boolean;
|
|
26
26
|
hasModOperator: boolean;
|
|
27
|
+
sqlLateralJoinBag(expressions: LateralJoinExpression[]): string;
|
|
27
28
|
nestedArrays: boolean;
|
|
28
29
|
supportsHyperLogLog: boolean;
|
|
29
30
|
likeEscape: boolean;
|
|
@@ -36,7 +37,7 @@ export declare class StandardSQLDialect extends Dialect {
|
|
|
36
37
|
sqlGroupSetTable(groupSetCount: number): string;
|
|
37
38
|
sqlAnyValue(groupSet: number, fieldName: string): string;
|
|
38
39
|
sqlOrderBy(orderTerms: string[], obr?: OrderByRequest): string;
|
|
39
|
-
sqlAggregateTurtle(groupSet: number, fieldList: DialectFieldList, orderBy:
|
|
40
|
+
sqlAggregateTurtle(groupSet: number, fieldList: DialectFieldList, orderBy: CompiledOrderBy[] | undefined): string;
|
|
40
41
|
sqlAnyValueTurtle(groupSet: number, fieldList: DialectFieldList): string;
|
|
41
42
|
sqlAnyValueLastTurtle(name: string, groupSet: number, sqlName: string): string;
|
|
42
43
|
sqlCoaleseMeasuresInline(groupSet: number, fieldList: DialectFieldList): string;
|
|
@@ -102,6 +102,10 @@ class StandardSQLDialect extends dialect_1.Dialect {
|
|
|
102
102
|
{ min: dialect_1.MIN_INT64, max: dialect_1.MAX_INT64, numberType: 'bigint' },
|
|
103
103
|
];
|
|
104
104
|
}
|
|
105
|
+
sqlLateralJoinBag(expressions) {
|
|
106
|
+
const fields = expressions.map(e => `${e.sql} as ${e.name}`);
|
|
107
|
+
return `LEFT JOIN UNNEST([STRUCT(${fields.join(',\n')})]) as __lateral_join_bag\n`;
|
|
108
|
+
}
|
|
105
109
|
quoteTablePath(tablePath) {
|
|
106
110
|
return `\`${tablePath}\``;
|
|
107
111
|
}
|
|
@@ -133,7 +137,8 @@ class StandardSQLDialect extends dialect_1.Dialect {
|
|
|
133
137
|
const fields = fieldList
|
|
134
138
|
.map(f => `\n ${f.sqlExpression} as ${f.sqlOutputName}`)
|
|
135
139
|
.join(', ');
|
|
136
|
-
|
|
140
|
+
const orderByClause = orderBy ? this.sqlTurtleOrderByClause(orderBy) : '';
|
|
141
|
+
return `ARRAY_AGG(CASE WHEN group_set=${groupSet} THEN STRUCT(${fields}\n ) END IGNORE NULLS ${orderByClause})`;
|
|
137
142
|
}
|
|
138
143
|
sqlAnyValueTurtle(groupSet, fieldList) {
|
|
139
144
|
const fields = fieldList
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Expr, Sampling, AtomicTypeDef, ATimestampTypeDef, TypecastExpr, RegexMatchExpr, MeasureTimeExpr, TimeExtractExpr, BasicAtomicTypeDef, RecordLiteralNode } from '../../model/malloy_types';
|
|
2
2
|
import type { DialectFunctionOverloadDef } from '../functions';
|
|
3
|
-
import type { DialectFieldList, OrderByClauseType, QueryInfo } from '../dialect';
|
|
3
|
+
import type { CompiledOrderBy, DialectFieldList, OrderByClauseType, QueryInfo } from '../dialect';
|
|
4
4
|
import { PostgresBase } from '../pg_impl';
|
|
5
5
|
export declare class TrinoDialect extends PostgresBase {
|
|
6
6
|
name: string;
|
|
@@ -35,7 +35,7 @@ export declare class TrinoDialect extends PostgresBase {
|
|
|
35
35
|
exprToSQL(qi: QueryInfo, df: Expr): string | undefined;
|
|
36
36
|
sqlAnyValue(groupSet: number, fieldName: string): string;
|
|
37
37
|
buildTypeExpression(fieldList: DialectFieldList): string;
|
|
38
|
-
sqlAggregateTurtle(groupSet: number, fieldList: DialectFieldList, orderBy:
|
|
38
|
+
sqlAggregateTurtle(groupSet: number, fieldList: DialectFieldList, orderBy: CompiledOrderBy[] | undefined): string;
|
|
39
39
|
sqlAnyValueTurtle(groupSet: number, fieldList: DialectFieldList): string;
|
|
40
40
|
sqlAnyValueLastTurtle(name: string, groupSet: number, sqlName: string): string;
|
|
41
41
|
sqlCoaleseMeasuresInline(groupSet: number, fieldList: DialectFieldList): string;
|
|
@@ -232,7 +232,8 @@ class TrinoDialect extends pg_impl_1.PostgresBase {
|
|
|
232
232
|
sqlAggregateTurtle(groupSet, fieldList, orderBy) {
|
|
233
233
|
const expressions = fieldList.map(f => f.sqlExpression).join(',\n ');
|
|
234
234
|
const definitions = this.buildTypeExpression(fieldList);
|
|
235
|
-
|
|
235
|
+
const orderByClause = orderBy ? this.sqlTurtleOrderByClause(orderBy) : '';
|
|
236
|
+
return `ARRAY_AGG(CAST(ROW(${expressions}) AS ROW(${definitions})) ${orderByClause}) FILTER (WHERE group_set=${groupSet})`;
|
|
236
237
|
}
|
|
237
238
|
sqlAnyValueTurtle(groupSet, fieldList) {
|
|
238
239
|
const expressions = fieldList.map(f => f.sqlExpression).join(',\n ');
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
1
|
+
export { DuckDBDialect, StandardSQLDialect, TrinoDialect, PostgresDialect, SnowflakeDialect, MySQLDialect, DatabricksDialect, 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
3
|
export type { QueryRecord, 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, BuildID, BuildManifest, BuildManifestEntry, } from './model';
|
|
4
4
|
export { isSourceDef, isAtomic, isBasicAtomic, isCompoundArrayData, isJoined, isJoinedSource, isSamplingEnable, isSamplingPercent, isSamplingRows, isRepeatedRecord, isBasicArray, mkArrayDef, mkFieldDef, expressionIsAggregate, expressionIsAnalytic, expressionIsCalculation, expressionIsScalar, expressionIsUngroupedAggregate, indent, composeSQLExpr, isTimestampUnit, isDateUnit, constantExprToSQL, } from './model';
|
package/dist/index.js
CHANGED
|
@@ -33,8 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
37
|
-
exports.makeDigest = exports.EMPTY_BUILD_MANIFEST = exports.PersistSource = exports.annotationToTaglines = exports.annotationToTag = exports.sqlKey = exports.API = exports.sourceDefToSourceInfo = exports.modelDefToModelInfo = exports.toAsyncGenerator = exports.resolveValue = exports.isValueRef = exports.getRegisteredConnectionTypes = exports.getConnectionTypeDisplayName = exports.getConnectionProperties = exports.registerConnectionType = exports.MalloyConfig = exports.Manifest = 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 = exports.ConnectionRuntime = exports.AtomicFieldType = void 0;
|
|
36
|
+
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.isCompoundArrayData = exports.isBasicAtomic = exports.isAtomic = 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.DatabricksDialect = exports.MySQLDialect = exports.SnowflakeDialect = exports.PostgresDialect = exports.TrinoDialect = exports.StandardSQLDialect = exports.DuckDBDialect = void 0;
|
|
37
|
+
exports.makeDigest = exports.EMPTY_BUILD_MANIFEST = exports.PersistSource = exports.annotationToTaglines = exports.annotationToTag = exports.sqlKey = exports.API = exports.sourceDefToSourceInfo = exports.modelDefToModelInfo = exports.toAsyncGenerator = exports.resolveValue = exports.isValueRef = exports.getRegisteredConnectionTypes = exports.getConnectionTypeDisplayName = exports.getConnectionProperties = exports.registerConnectionType = exports.MalloyConfig = exports.Manifest = 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 = exports.ConnectionRuntime = exports.AtomicFieldType = exports.Runtime = void 0;
|
|
38
38
|
/*
|
|
39
39
|
* Copyright 2023 Google LLC
|
|
40
40
|
*
|
|
@@ -64,6 +64,7 @@ Object.defineProperty(exports, "TrinoDialect", { enumerable: true, get: function
|
|
|
64
64
|
Object.defineProperty(exports, "PostgresDialect", { enumerable: true, get: function () { return dialect_1.PostgresDialect; } });
|
|
65
65
|
Object.defineProperty(exports, "SnowflakeDialect", { enumerable: true, get: function () { return dialect_1.SnowflakeDialect; } });
|
|
66
66
|
Object.defineProperty(exports, "MySQLDialect", { enumerable: true, get: function () { return dialect_1.MySQLDialect; } });
|
|
67
|
+
Object.defineProperty(exports, "DatabricksDialect", { enumerable: true, get: function () { return dialect_1.DatabricksDialect; } });
|
|
67
68
|
Object.defineProperty(exports, "registerDialect", { enumerable: true, get: function () { return dialect_1.registerDialect; } });
|
|
68
69
|
Object.defineProperty(exports, "arg", { enumerable: true, get: function () { return dialect_1.arg; } });
|
|
69
70
|
Object.defineProperty(exports, "qtz", { enumerable: true, get: function () { return dialect_1.qtz; } });
|
|
@@ -5,5 +5,5 @@ export declare abstract class QueryBase extends MalloyElement {
|
|
|
5
5
|
abstract queryComp(isRefOk: boolean): QueryComp;
|
|
6
6
|
protected expandFieldUsage(inputSource: SourceDef, pipeline: PipeSegment[]): PipeSegment[];
|
|
7
7
|
protected resolveCompositeSource(inputSource: SourceDef, pipeline: PipeSegment[]): SourceDef | undefined;
|
|
8
|
-
query(): Query;
|
|
8
|
+
query(isRefOk?: boolean): Query;
|
|
9
9
|
}
|
|
@@ -57,8 +57,8 @@ class QueryBase extends malloy_element_1.MalloyElement {
|
|
|
57
57
|
}
|
|
58
58
|
return undefined;
|
|
59
59
|
}
|
|
60
|
-
query() {
|
|
61
|
-
const { query } = this.queryComp(
|
|
60
|
+
query(isRefOk = true) {
|
|
61
|
+
const { query } = this.queryComp(isRefOk);
|
|
62
62
|
return {
|
|
63
63
|
...query,
|
|
64
64
|
pipeline: (0, query_utils_1.detectAndRemovePartialStages)(query.pipeline, this),
|
|
@@ -71,8 +71,8 @@ class QueryReference extends malloy_element_1.MalloyElement {
|
|
|
71
71
|
this.logError('non-query-used-as-query', `Illegal reference to '${this.name}', query expected`);
|
|
72
72
|
return oops();
|
|
73
73
|
}
|
|
74
|
-
query() {
|
|
75
|
-
return this.queryComp(
|
|
74
|
+
query(isRefOk = true) {
|
|
75
|
+
return this.queryComp(isRefOk).query;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
exports.QueryReference = QueryReference;
|
|
@@ -77,7 +77,7 @@ class SQLString extends malloy_element_1.MalloyElement {
|
|
|
77
77
|
// Not a source - try as a query
|
|
78
78
|
const queryObject = el.getQuery();
|
|
79
79
|
if (queryObject) {
|
|
80
|
-
ret.push(queryObject.query());
|
|
80
|
+
ret.push(queryObject.query(false));
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
83
|
el.sqLog('failed-to-expand-sql-source', 'Cannot expand into a query');
|
|
@@ -3,6 +3,6 @@ import type { Query } from '../../../model/malloy_types';
|
|
|
3
3
|
import type { QueryComp } from './query-comp';
|
|
4
4
|
export interface QueryElement extends MalloyElement {
|
|
5
5
|
queryComp(isRefOk: boolean): QueryComp;
|
|
6
|
-
query(): Query;
|
|
6
|
+
query(isRefOk?: boolean): Query;
|
|
7
7
|
}
|
|
8
8
|
export declare function isQueryElement(e: MalloyElement): e is QueryElement;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Generated from MalloyLexer.g4 by ANTLR 4.9.0-SNAPSHOT
|
|
2
|
+
// Generated from src/lang/grammar/MalloyLexer.g4 by ANTLR 4.9.0-SNAPSHOT
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Generated from MalloyParser.g4 by ANTLR 4.9.0-SNAPSHOT
|
|
2
|
+
// Generated from src/lang/grammar/MalloyParser.g4 by ANTLR 4.9.0-SNAPSHOT
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|