@malloydata/render 0.0.104-dev231117214047 → 0.0.104
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/drill.js +16 -8
- package/package.json +2 -2
package/dist/drill.js
CHANGED
|
@@ -26,7 +26,7 @@ exports.getDrillQuery = exports.getDrillFilters = void 0;
|
|
|
26
26
|
const malloy_1 = require("@malloydata/malloy");
|
|
27
27
|
const utils_1 = require("./html/utils");
|
|
28
28
|
function filterQuote(s) {
|
|
29
|
-
return `'${s.replace(
|
|
29
|
+
return `'${s.replace(/(['\\])/g, '\\$1')}'`;
|
|
30
30
|
}
|
|
31
31
|
function timestampToDateFilter(key, value, timeframe) {
|
|
32
32
|
const adjustedTimeframe = timeframe === malloy_1.TimestampTimeframe.Minute
|
|
@@ -50,7 +50,11 @@ function getRowFilters(row) {
|
|
|
50
50
|
for (const dim of dimensions) {
|
|
51
51
|
const cell = row.cell(dim);
|
|
52
52
|
// if we have an expression, use it instead of the name of the field.
|
|
53
|
-
|
|
53
|
+
let key = dim.isAtomicField() || dim.isQueryField() ? dim.expression : undefined;
|
|
54
|
+
// Multi word column names.
|
|
55
|
+
if (key !== undefined && key.includes(' ') && key === dim.name) {
|
|
56
|
+
key = '`' + key + '`';
|
|
57
|
+
}
|
|
54
58
|
if (key && !cell.isArray()) {
|
|
55
59
|
if (cell.isNull()) {
|
|
56
60
|
filters.push({ key, value: 'null' });
|
|
@@ -62,7 +66,12 @@ function getRowFilters(row) {
|
|
|
62
66
|
filters.push({ key, value: cell.value.toString() });
|
|
63
67
|
}
|
|
64
68
|
else if (cell.isTimestamp() || cell.isDate()) {
|
|
65
|
-
|
|
69
|
+
let timeframe = cell.field.timeframe;
|
|
70
|
+
// Dont let the timeframe for Date go down to seconds.
|
|
71
|
+
if (cell.isDate() && timeframe === undefined) {
|
|
72
|
+
timeframe = malloy_1.DateTimeframe.Day;
|
|
73
|
+
}
|
|
74
|
+
filters.push(timestampToDateFilter(key, cell.value, timeframe));
|
|
66
75
|
}
|
|
67
76
|
}
|
|
68
77
|
}
|
|
@@ -88,7 +97,7 @@ function getDrillFilters(data) {
|
|
|
88
97
|
const formattedFilters = [];
|
|
89
98
|
for (const { key, value } of filters) {
|
|
90
99
|
if (value !== undefined) {
|
|
91
|
-
formattedFilters.push(`${key}
|
|
100
|
+
formattedFilters.push(`${key} = ${value}`);
|
|
92
101
|
}
|
|
93
102
|
else {
|
|
94
103
|
formattedFilters.push(key);
|
|
@@ -102,12 +111,11 @@ function getDrillFilters(data) {
|
|
|
102
111
|
exports.getDrillFilters = getDrillFilters;
|
|
103
112
|
function getDrillQuery(data) {
|
|
104
113
|
const { formattedFilters, source } = getDrillFilters(data);
|
|
105
|
-
let ret = `run: ${(source === null || source === void 0 ? void 0 : source.name) || '"unable to compute source"'} `;
|
|
114
|
+
let ret = `run: ${(source === null || source === void 0 ? void 0 : source.name) || '"unable to compute source"'} -> `;
|
|
106
115
|
if (formattedFilters.length) {
|
|
107
|
-
ret += `{ \n where: \n ${formattedFilters.join(',\n ')}\n \n}\n`;
|
|
116
|
+
ret += `{ \n select: *\n where: \n ${formattedFilters.join(',\n ')}\n \n}\n`;
|
|
108
117
|
}
|
|
109
|
-
|
|
110
|
-
return { drillQuery, drillFilters: formattedFilters };
|
|
118
|
+
return { drillQuery: ret, drillFilters: formattedFilters };
|
|
111
119
|
}
|
|
112
120
|
exports.getDrillQuery = getDrillQuery;
|
|
113
121
|
//# sourceMappingURL=drill.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/render",
|
|
3
|
-
"version": "0.0.104
|
|
3
|
+
"version": "0.0.104",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"build-storybook": "storybook build"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@malloydata/malloy": "^0.0.104
|
|
26
|
+
"@malloydata/malloy": "^0.0.104",
|
|
27
27
|
"@types/luxon": "^2.4.0",
|
|
28
28
|
"lit": "^3.0.2",
|
|
29
29
|
"lodash": "^4.17.20",
|