@malloydata/malloy 0.0.332 → 0.0.334
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/lang/ast/source-elements/refined-source.js +2 -1
- package/dist/malloy.d.ts +5 -0
- package/dist/malloy.js +15 -0
- package/dist/model/expression_compiler.js +1 -0
- package/dist/model/filter_compilers.d.ts +3 -3
- package/dist/model/filter_compilers.js +1 -1
- package/dist/model/query_query.js +27 -25
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
|
@@ -138,7 +138,8 @@ class RefinedSource extends source_1.Source {
|
|
|
138
138
|
fs.addAccessModifiers(thisIncludeState.modifiers);
|
|
139
139
|
fs.addNotes(thisIncludeState.notes);
|
|
140
140
|
const retStruct = fs.structDef();
|
|
141
|
-
|
|
141
|
+
// Clone the filterList to avoid mutating the original source's filters
|
|
142
|
+
const filterList = retStruct.filterList ? [...retStruct.filterList] : [];
|
|
142
143
|
let moreFilters = false;
|
|
143
144
|
for (const filter of filters) {
|
|
144
145
|
for (const el of filter.list) {
|
package/dist/malloy.d.ts
CHANGED
|
@@ -484,6 +484,11 @@ export declare class PreparedResult implements Taggable {
|
|
|
484
484
|
get _sourceExploreName(): string;
|
|
485
485
|
get _sourceArguments(): Record<string, Argument> | undefined;
|
|
486
486
|
get _sourceFilters(): FilterCondition[];
|
|
487
|
+
/**
|
|
488
|
+
* @return Whether this result has a schema. DDL statements (INSTALL, LOAD,
|
|
489
|
+
* CREATE SECRET, etc.) do not return a schema.
|
|
490
|
+
*/
|
|
491
|
+
get hasSchema(): boolean;
|
|
487
492
|
}
|
|
488
493
|
/**
|
|
489
494
|
* A URL reader which always throws an error when a URL's contents is requested.
|
package/dist/malloy.js
CHANGED
|
@@ -889,6 +889,13 @@ class PreparedResult {
|
|
|
889
889
|
get _sourceFilters() {
|
|
890
890
|
return this.inner.sourceFilters || [];
|
|
891
891
|
}
|
|
892
|
+
/**
|
|
893
|
+
* @return Whether this result has a schema. DDL statements (INSTALL, LOAD,
|
|
894
|
+
* CREATE SECRET, etc.) do not return a schema.
|
|
895
|
+
*/
|
|
896
|
+
get hasSchema() {
|
|
897
|
+
return this.inner.structs.length > 0;
|
|
898
|
+
}
|
|
892
899
|
}
|
|
893
900
|
exports.PreparedResult = PreparedResult;
|
|
894
901
|
/**
|
|
@@ -2432,6 +2439,14 @@ class Result extends PreparedResult {
|
|
|
2432
2439
|
return this.inner.profilingUrl;
|
|
2433
2440
|
}
|
|
2434
2441
|
toJSON() {
|
|
2442
|
+
// DDL statements (INSTALL, LOAD, CREATE SECRET, etc.) don't have a schema,
|
|
2443
|
+
// so we can't call this.data.toJSON() which requires resultExplore.
|
|
2444
|
+
if (!this.hasSchema) {
|
|
2445
|
+
return {
|
|
2446
|
+
queryResult: this.inner,
|
|
2447
|
+
modelDef: this._modelDef,
|
|
2448
|
+
};
|
|
2449
|
+
}
|
|
2435
2450
|
// The result rows are converted to JSON separately because they
|
|
2436
2451
|
// may contain un-serializable data types.
|
|
2437
2452
|
return {
|
|
@@ -6,7 +6,7 @@ export declare const FilterCompilers: {
|
|
|
6
6
|
numberCompile(nc: NumberFilter, x: string, d: Dialect): string;
|
|
7
7
|
booleanCompile(bc: BooleanFilter, x: string, d: Dialect): string;
|
|
8
8
|
stringCompile(sc: StringFilter, x: string, d: Dialect): string;
|
|
9
|
-
temporalCompile(tc: TemporalFilter, x: string, d: Dialect, t: "date" | "timestamp", qi?: QueryInfo): string;
|
|
9
|
+
temporalCompile(tc: TemporalFilter, x: string, d: Dialect, t: "date" | "timestamp" | "timestamptz", qi?: QueryInfo): string;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* I felt like there was enough "helpful functions needed to make everything
|
|
@@ -16,10 +16,10 @@ export declare const FilterCompilers: {
|
|
|
16
16
|
*/
|
|
17
17
|
export declare class TemporalFilterCompiler {
|
|
18
18
|
readonly expr: string;
|
|
19
|
-
readonly timetype: 'timestamp' | 'date';
|
|
19
|
+
readonly timetype: 'timestamp' | 'timestamptz' | 'date';
|
|
20
20
|
readonly d: Dialect;
|
|
21
21
|
readonly qi: QueryInfo;
|
|
22
|
-
constructor(expr: string, dialect: Dialect, timetype?: 'timestamp' | 'date', queryInfo?: QueryInfo);
|
|
22
|
+
constructor(expr: string, dialect: Dialect, timetype?: 'timestamp' | 'timestamptz' | 'date', queryInfo?: QueryInfo);
|
|
23
23
|
time(timeSQL: string): string;
|
|
24
24
|
compile(tc: TemporalFilter): string;
|
|
25
25
|
private expandLiteral;
|
|
@@ -47,7 +47,7 @@ exports.FilterCompilers = {
|
|
|
47
47
|
else if (t === 'boolean' && (0, malloy_filter_1.isBooleanFilter)(c)) {
|
|
48
48
|
return exports.FilterCompilers.booleanCompile(c, x, d);
|
|
49
49
|
}
|
|
50
|
-
else if ((
|
|
50
|
+
else if ((0, malloy_types_1.isTemporalType)(t) && (0, malloy_filter_1.isTemporalFilter)(c)) {
|
|
51
51
|
return exports.FilterCompilers.temporalCompile(c, x, d, t, qi);
|
|
52
52
|
}
|
|
53
53
|
throw new Error('INTERNAL ERROR: No filter compiler for ' + t);
|
|
@@ -1052,6 +1052,7 @@ class QueryQuery extends query_node_1.QueryField {
|
|
|
1052
1052
|
let orderingField;
|
|
1053
1053
|
const orderByDef = result.firstSegment.orderBy ||
|
|
1054
1054
|
result.calculateDefaultOrderBy();
|
|
1055
|
+
// Build up the ORDER BY clause from all ordering fields
|
|
1055
1056
|
for (const ordering of orderByDef) {
|
|
1056
1057
|
if (typeof ordering.field === 'string') {
|
|
1057
1058
|
orderingField = {
|
|
@@ -1065,31 +1066,32 @@ class QueryQuery extends query_node_1.QueryField {
|
|
|
1065
1066
|
obSQL.push(' ' +
|
|
1066
1067
|
this.parent.dialect.sqlMaybeQuoteIdentifier(`${orderingField.name}__${result.groupSet}`) +
|
|
1067
1068
|
` ${ordering.dir || 'ASC'}`);
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1069
|
+
}
|
|
1070
|
+
// partition for a row number is the parent if it exists.
|
|
1071
|
+
let p = '';
|
|
1072
|
+
if (result.parent && partitionSQL[result.parent.groupSet]) {
|
|
1073
|
+
p = partitionSQL[result.parent.groupSet] + ', group_set';
|
|
1074
|
+
}
|
|
1075
|
+
else {
|
|
1076
|
+
p = 'PARTITION BY group_set';
|
|
1077
|
+
}
|
|
1078
|
+
// if this has nested data and a having, we want to partition by the 'having' so we don't count
|
|
1079
|
+
// deleted rows.
|
|
1080
|
+
if (result.hasHaving) {
|
|
1081
|
+
p = p + `, __delete__${result.groupSet}`;
|
|
1082
|
+
}
|
|
1083
|
+
// Generate a single ROW_NUMBER() with all ORDER BY fields
|
|
1084
|
+
limitExpressions.push(`CASE WHEN GROUP_SET=${result.groupSet} THEN
|
|
1085
|
+
ROW_NUMBER() OVER (${p} ORDER BY ${obSQL.join(',')}) END as __row_number__${result.groupSet}`);
|
|
1086
|
+
// if the group set is a leaf, we can write a simple where clause.
|
|
1087
|
+
const filterClause = `(GROUP_SET = ${result.groupSet} AND __row_number__${result.groupSet} > ${limitValues[result.groupSet]})`;
|
|
1088
|
+
if (result.childGroups.length === 1) {
|
|
1089
|
+
limitSimpleFilters.push(filterClause);
|
|
1090
|
+
}
|
|
1091
|
+
else {
|
|
1092
|
+
// its a complex
|
|
1093
|
+
limitComplexClauses[result.groupSet] =
|
|
1094
|
+
`CASE WHEN ${filterClause} THEN 1 ELSE 0 END`;
|
|
1093
1095
|
}
|
|
1094
1096
|
}
|
|
1095
1097
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MALLOY_VERSION = "0.0.
|
|
1
|
+
export declare const MALLOY_VERSION = "0.0.334";
|
package/dist/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MALLOY_VERSION = void 0;
|
|
4
4
|
// generated with 'generate-version-file' script; do not edit manually
|
|
5
|
-
exports.MALLOY_VERSION = '0.0.
|
|
5
|
+
exports.MALLOY_VERSION = '0.0.334';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.334",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"generate-version-file": "VERSION=$(npm pkg get version --workspaces=false | tr -d \\\")\necho \"// generated with 'generate-version-file' script; do not edit manually\\nexport const MALLOY_VERSION = '$VERSION';\" > src/version.ts"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@malloydata/malloy-filter": "0.0.
|
|
49
|
-
"@malloydata/malloy-interfaces": "0.0.
|
|
50
|
-
"@malloydata/malloy-tag": "0.0.
|
|
48
|
+
"@malloydata/malloy-filter": "0.0.334",
|
|
49
|
+
"@malloydata/malloy-interfaces": "0.0.334",
|
|
50
|
+
"@malloydata/malloy-tag": "0.0.334",
|
|
51
51
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
52
52
|
"assert": "^2.0.0",
|
|
53
53
|
"jaro-winkler": "^0.2.8",
|