@malloydata/malloy 0.0.224-dev241217161218 → 0.0.224-dev241217193641
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/dialect/trino/dialect_functions.js +9 -9
- package/dist/lang/ast/query-elements/query-arrow.js +10 -4
- package/dist/lang/ast/query-elements/query-base.d.ts +2 -1
- package/dist/lang/ast/query-elements/query-base.js +11 -10
- package/dist/lang/ast/query-elements/query-refine.js +7 -2
- package/package.json +1 -1
|
@@ -69,7 +69,7 @@ const hll_accumulate = {
|
|
|
69
69
|
'T': ['string', 'number', 'date', 'timestamp', 'boolean', 'json'],
|
|
70
70
|
},
|
|
71
71
|
takes: { 'value': { dimension: { generic: 'T' } } },
|
|
72
|
-
returns: { measure: '
|
|
72
|
+
returns: { measure: { sql_native: 'hyperloglog' } },
|
|
73
73
|
isSymmetric: true,
|
|
74
74
|
impl: {
|
|
75
75
|
function: 'APPROX_SET',
|
|
@@ -80,7 +80,7 @@ const hll_accumulate = {
|
|
|
80
80
|
'T': ['string', 'number', 'date', 'timestamp', 'boolean', 'json'],
|
|
81
81
|
},
|
|
82
82
|
takes: { 'value': { dimension: { generic: 'T' } }, 'accuracy': 'number' },
|
|
83
|
-
returns: { measure: '
|
|
83
|
+
returns: { measure: { sql_native: 'hyperloglog' } },
|
|
84
84
|
isSymmetric: true,
|
|
85
85
|
impl: {
|
|
86
86
|
function: 'APPROX_SET',
|
|
@@ -89,33 +89,33 @@ const hll_accumulate = {
|
|
|
89
89
|
};
|
|
90
90
|
const hll_combine = {
|
|
91
91
|
takes: {
|
|
92
|
-
'value': '
|
|
92
|
+
'value': { sql_native: 'hyperloglog' },
|
|
93
93
|
},
|
|
94
|
-
returns: { measure: '
|
|
94
|
+
returns: { measure: { sql_native: 'hyperloglog' } },
|
|
95
95
|
impl: { function: 'MERGE' },
|
|
96
96
|
isSymmetric: true,
|
|
97
97
|
};
|
|
98
98
|
const hll_estimate = {
|
|
99
99
|
takes: {
|
|
100
|
-
'value': '
|
|
100
|
+
'value': { sql_native: 'hyperloglog' },
|
|
101
101
|
},
|
|
102
102
|
returns: { dimension: 'number' },
|
|
103
103
|
impl: { function: 'CARDINALITY' },
|
|
104
104
|
};
|
|
105
105
|
const hll_export = {
|
|
106
106
|
takes: {
|
|
107
|
-
'value': '
|
|
107
|
+
'value': { sql_native: 'hyperloglog' },
|
|
108
108
|
},
|
|
109
|
-
returns: { dimension: '
|
|
109
|
+
returns: { dimension: { sql_native: 'varbinary' } },
|
|
110
110
|
impl: {
|
|
111
111
|
sql: 'CAST(${value} AS VARBINARY)',
|
|
112
112
|
},
|
|
113
113
|
};
|
|
114
114
|
const hll_import = {
|
|
115
115
|
takes: {
|
|
116
|
-
'value': '
|
|
116
|
+
'value': { sql_native: 'varbinary' },
|
|
117
117
|
},
|
|
118
|
-
returns: { dimension: '
|
|
118
|
+
returns: { dimension: { sql_native: 'hyperloglog' } },
|
|
119
119
|
impl: {
|
|
120
120
|
sql: 'CAST(${value} AS HyperLogLog)',
|
|
121
121
|
},
|
|
@@ -40,6 +40,7 @@ class QueryArrow extends query_base_1.QueryBase {
|
|
|
40
40
|
this.elementType = 'arrow';
|
|
41
41
|
}
|
|
42
42
|
queryComp(isRefOk) {
|
|
43
|
+
var _a;
|
|
43
44
|
let inputStruct;
|
|
44
45
|
let queryBase;
|
|
45
46
|
let fieldSpace;
|
|
@@ -68,12 +69,17 @@ class QueryArrow extends query_base_1.QueryBase {
|
|
|
68
69
|
fieldSpace = new static_space_1.StaticSourceSpace(lhsQuery.outputStruct);
|
|
69
70
|
}
|
|
70
71
|
const { pipeline, annotation, outputStruct, name } = this.view.pipelineComp(fieldSpace);
|
|
72
|
+
const query = {
|
|
73
|
+
...queryBase,
|
|
74
|
+
name,
|
|
75
|
+
annotation,
|
|
76
|
+
pipeline: [...queryBase.pipeline, ...pipeline],
|
|
77
|
+
};
|
|
78
|
+
const compositeResolvedSourceDef = (_a = query.compositeResolvedSourceDef) !== null && _a !== void 0 ? _a : this.resolveCompositeSource(inputStruct, query);
|
|
71
79
|
return {
|
|
72
80
|
query: {
|
|
73
|
-
...
|
|
74
|
-
|
|
75
|
-
annotation,
|
|
76
|
-
pipeline: [...queryBase.pipeline, ...pipeline],
|
|
81
|
+
...query,
|
|
82
|
+
compositeResolvedSourceDef,
|
|
77
83
|
},
|
|
78
84
|
outputStruct,
|
|
79
85
|
inputStruct,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Query } from '../../../model/malloy_types';
|
|
1
|
+
import { Query, SourceDef } from '../../../model/malloy_types';
|
|
2
2
|
import { MalloyElement } from '../types/malloy-element';
|
|
3
3
|
import { QueryComp } from '../types/query-comp';
|
|
4
4
|
export declare abstract class QueryBase extends MalloyElement {
|
|
5
5
|
abstract queryComp(isRefOk: boolean): QueryComp;
|
|
6
|
+
protected resolveCompositeSource(inputSource: SourceDef, query: Query): SourceDef | undefined;
|
|
6
7
|
query(): Query;
|
|
7
8
|
}
|
|
@@ -28,23 +28,24 @@ const malloy_types_1 = require("../../../model/malloy_types");
|
|
|
28
28
|
const query_utils_1 = require("../query-utils");
|
|
29
29
|
const malloy_element_1 = require("../types/malloy-element");
|
|
30
30
|
class QueryBase extends malloy_element_1.MalloyElement {
|
|
31
|
-
query
|
|
31
|
+
resolveCompositeSource(inputSource, query) {
|
|
32
32
|
var _a;
|
|
33
|
-
const
|
|
33
|
+
const stage1 = query.pipeline[0];
|
|
34
34
|
// TODO add an error if a raw query is done against a composite source
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
((0, malloy_types_1.isQuerySegment)(query.pipeline[0]) || (0, malloy_types_1.isIndexSegment)(query.pipeline[0]))) {
|
|
38
|
-
const compositeFieldUsage = (_a = query.pipeline[0].compositeFieldUsage) !== null && _a !== void 0 ? _a : (0, composite_source_utils_1.emptyCompositeFieldUsage)();
|
|
35
|
+
if (stage1 && ((0, malloy_types_1.isQuerySegment)(stage1) || (0, malloy_types_1.isIndexSegment)(stage1))) {
|
|
36
|
+
const compositeFieldUsage = (_a = stage1.compositeFieldUsage) !== null && _a !== void 0 ? _a : (0, composite_source_utils_1.emptyCompositeFieldUsage)();
|
|
39
37
|
if (!(0, composite_source_utils_1.isEmptyCompositeFieldUsage)(compositeFieldUsage) ||
|
|
40
|
-
|
|
41
|
-
const resolved = (0, composite_source_utils_1.resolveCompositeSources)(
|
|
42
|
-
|
|
38
|
+
inputSource.type === 'composite') {
|
|
39
|
+
const resolved = (0, composite_source_utils_1.resolveCompositeSources)(inputSource, compositeFieldUsage);
|
|
40
|
+
return resolved.sourceDef;
|
|
43
41
|
}
|
|
44
42
|
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
query() {
|
|
46
|
+
const { query } = this.queryComp(true);
|
|
45
47
|
return {
|
|
46
48
|
...query,
|
|
47
|
-
compositeResolvedSourceDef,
|
|
48
49
|
pipeline: (0, query_utils_1.detectAndRemovePartialStages)(query.pipeline, this),
|
|
49
50
|
};
|
|
50
51
|
}
|
|
@@ -42,10 +42,15 @@ class QueryRefine extends query_base_1.QueryBase {
|
|
|
42
42
|
const q = this.base.queryComp(isRefOk);
|
|
43
43
|
const inputFS = new static_space_1.StaticSourceSpace(q.inputStruct);
|
|
44
44
|
const resultPipe = this.refinement.refine(inputFS, q.query.pipeline, undefined);
|
|
45
|
+
const query = {
|
|
46
|
+
...q.query,
|
|
47
|
+
pipeline: resultPipe,
|
|
48
|
+
};
|
|
49
|
+
const compositeResolvedSourceDef = this.resolveCompositeSource(q.inputStruct, query);
|
|
45
50
|
return {
|
|
46
51
|
query: {
|
|
47
|
-
...
|
|
48
|
-
|
|
52
|
+
...query,
|
|
53
|
+
compositeResolvedSourceDef,
|
|
49
54
|
},
|
|
50
55
|
outputStruct: (0, struct_utils_1.getFinalStruct)(this.refinement, q.inputStruct, resultPipe),
|
|
51
56
|
inputStruct: q.inputStruct,
|