@malloydata/malloyyo 0.2.63 → 0.2.65
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.js +33 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { dirname, join } from "node:path";
|
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
|
|
13
13
|
// package.json
|
|
14
|
-
var version = "0.2.
|
|
14
|
+
var version = "0.2.65";
|
|
15
15
|
|
|
16
16
|
// src/update-check.ts
|
|
17
17
|
var UPDATE_CHECK_ARGV = "__update-check";
|
|
@@ -1247,6 +1247,36 @@ function jsonRows(result) {
|
|
|
1247
1247
|
}
|
|
1248
1248
|
return result.data.toObject().map((row) => jsonValue(row));
|
|
1249
1249
|
}
|
|
1250
|
+
function columnType(t) {
|
|
1251
|
+
switch (t.kind) {
|
|
1252
|
+
case "number_type":
|
|
1253
|
+
return t.subtype ? { type: "number", subtype: t.subtype } : { type: "number" };
|
|
1254
|
+
case "date_type":
|
|
1255
|
+
case "timestamp_type":
|
|
1256
|
+
case "timestamptz_type": {
|
|
1257
|
+
const type = t.kind.replace(/_type$/, "");
|
|
1258
|
+
return t.timeframe ? { type, timeframe: t.timeframe } : { type };
|
|
1259
|
+
}
|
|
1260
|
+
case "record_type":
|
|
1261
|
+
return { type: "record", fields: t.fields.map((f) => ({ name: f.name, ...columnType(f.type) })) };
|
|
1262
|
+
case "array_type": {
|
|
1263
|
+
const el = columnType(t.element_type);
|
|
1264
|
+
return el.type === "record" ? { type: "array", fields: el.fields } : { type: "array", element: el };
|
|
1265
|
+
}
|
|
1266
|
+
default:
|
|
1267
|
+
return { type: t.kind.replace(/_type$/, "") };
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
function resultColumns(result) {
|
|
1271
|
+
if (!result.hasSchema) return void 0;
|
|
1272
|
+
const out = [];
|
|
1273
|
+
for (const f of result.toStableResult().schema.fields) {
|
|
1274
|
+
if (f.kind === "dimension" || f.kind === "measure" || f.kind === "calculate") {
|
|
1275
|
+
out.push({ name: f.name, ...columnType(f.type) });
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
return out;
|
|
1279
|
+
}
|
|
1250
1280
|
function rowLimitTruncation(rowLimit) {
|
|
1251
1281
|
return {
|
|
1252
1282
|
reason: "row_limit",
|
|
@@ -1296,6 +1326,8 @@ async function executeMaterialized(query, opts, loadProblems, decorate = (p) =>
|
|
|
1296
1326
|
total_time_ms: t2 - t0,
|
|
1297
1327
|
problems: loadProblems
|
|
1298
1328
|
};
|
|
1329
|
+
const columns = resultColumns(results);
|
|
1330
|
+
if (columns) out.columns = columns;
|
|
1299
1331
|
if (rows.length === rowLimit) out.truncated = rowLimitTruncation(rowLimit);
|
|
1300
1332
|
if (opts.stableResult) out.stable_result = API.util.wrapResult(results);
|
|
1301
1333
|
return out;
|