@gscdump/engine 5.9.0 → 6.0.0
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TABLE_METADATA } from "../drizzle-schema.mjs";
|
|
2
2
|
import { SCHEMAS } from "../schema.mjs";
|
|
3
|
+
import { decompress } from "../node_modules/.pnpm/fzstd@0.1.1/node_modules/fzstd/esm/index.mjs";
|
|
3
4
|
import { parquetMetadataAsync, parquetSchema } from "../node_modules/.pnpm/hyparquet@1.31.1/node_modules/hyparquet/src/metadata.mjs";
|
|
4
5
|
import { parquetReadObjects } from "../node_modules/.pnpm/hyparquet@1.31.1/node_modules/hyparquet/src/read.mjs";
|
|
5
6
|
import "../node_modules/.pnpm/hyparquet@1.31.1/node_modules/hyparquet/src/node.mjs";
|
|
@@ -238,6 +239,7 @@ async function* decodeParquetGroups(bytes, opts = {}) {
|
|
|
238
239
|
const rowEnd = Math.min(groupEnd, opts.rowEnd ?? Infinity);
|
|
239
240
|
if (rowStart < rowEnd) yield normalizeDecodedDates(await parquetReadObjects({
|
|
240
241
|
file,
|
|
242
|
+
compressors: { ZSTD: (input) => decompress(input) },
|
|
241
243
|
metadata: {
|
|
242
244
|
...metadata,
|
|
243
245
|
row_groups: [group],
|
package/dist/parquet-plan.mjs
CHANGED
|
@@ -98,7 +98,7 @@ function compileLogicalQueryPlan(plan, table = plan.dataset) {
|
|
|
98
98
|
const having = buildHaving(plan.metricFilters);
|
|
99
99
|
const groupByCols = [...plan.groupByDimensions.map((dimension) => dimensionToColumn(dimension, table)), ...plan.hasDate ? ["date"] : []];
|
|
100
100
|
const groupBy = groupByCols.length > 0 ? `GROUP BY ${groupByCols.join(", ")}` : "";
|
|
101
|
-
const orderBy = plan.orderBy ? `ORDER BY ${plan.orderBy.column} ${plan.orderBy.dir.toUpperCase()}` : "ORDER BY clicks DESC"
|
|
101
|
+
const orderBy = `${plan.orderBy ? `ORDER BY ${plan.orderBy.column} ${plan.orderBy.dir.toUpperCase()}` : "ORDER BY clicks DESC"}${[...plan.groupByDimensions, ...plan.hasDate ? ["date"] : []].filter((d) => d !== plan.orderBy?.column).map((d) => `, ${d} ASC`).join("")}`;
|
|
102
102
|
const limit = `LIMIT ${plan.rowLimit ?? 1e3}`;
|
|
103
103
|
const offset = plan.startRow ? `OFFSET ${plan.startRow}` : "";
|
|
104
104
|
return {
|
|
@@ -28,19 +28,23 @@ function withMinimumImpressions(state, options) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
function orderByClause(state, prefix = "", columnOverride) {
|
|
31
|
+
const ties = dimensionOrder(state.dimensions, state.orderBy?.column, prefix);
|
|
31
32
|
if (state.orderBy) {
|
|
32
33
|
const safeCol = (columnOverride ?? state.orderBy.column).replace(/\W/g, "");
|
|
33
34
|
const safeDir = state.orderBy.dir.toUpperCase() === "ASC" ? "ASC" : "DESC";
|
|
34
|
-
return sql.raw(`ORDER BY ${prefix}${safeCol} ${safeDir}`);
|
|
35
|
+
return sql.raw(`ORDER BY ${prefix}${safeCol} ${safeDir}${ties}`);
|
|
35
36
|
}
|
|
36
|
-
return sql.raw(`ORDER BY ${prefix}clicks DESC`);
|
|
37
|
+
return sql.raw(`ORDER BY ${prefix}clicks DESC${ties}`);
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
+
function dimensionOrder(dimensions, primary, prefix = "") {
|
|
40
|
+
return [...new Set(dimensions)].filter((d) => d !== primary).map((d) => `, ${prefix}"${d.replace(/\W/g, "")}" ASC`).join("");
|
|
41
|
+
}
|
|
42
|
+
function changeOrderClause(order, dimensions) {
|
|
39
43
|
if (order.column !== "clicksChange") throw new Error(`[resolver] unknown comparison order column: ${JSON.stringify(order.column)}`);
|
|
40
44
|
if (order.dir !== "asc" && order.dir !== "desc") throw new Error(`[resolver] unknown comparison order direction: ${JSON.stringify(order.dir)}`);
|
|
41
45
|
return {
|
|
42
46
|
column: sql.raw("CAST(COALESCE(c.clicks, 0) AS DOUBLE) - CAST(COALESCE(p.clicks, 0) AS DOUBLE) as \"clicksChange\""),
|
|
43
|
-
orderBy: sql.raw(`ORDER BY clicksChange ${order.dir.toUpperCase()}`)
|
|
47
|
+
orderBy: sql.raw(`ORDER BY clicksChange ${order.dir.toUpperCase()}${dimensionOrder(dimensions)}`)
|
|
44
48
|
};
|
|
45
49
|
}
|
|
46
50
|
function limitOffsetClause(state) {
|
|
@@ -279,7 +283,7 @@ function resolveComparisonSQL(current, previous, options, comparisonFilter, comp
|
|
|
279
283
|
if (groupByExprs.length > 0) previousCte = sql`${previousCte} GROUP BY ${joinComma(groupByExprs)}`;
|
|
280
284
|
const joinOn = groupByDims.length > 0 ? sql.raw(groupByDims.map((d) => `c.${d.replace(/\W/g, "")} = p.${d.replace(/\W/g, "")}`).join(" AND ")) : sql.raw("1=1");
|
|
281
285
|
const filterClause = comparisonFilter ? COMPARISON_FILTER_SQL[comparisonFilter] : sql.raw("");
|
|
282
|
-
const changeOrder = comparisonOrderBy ? changeOrderClause(comparisonOrderBy) : void 0;
|
|
286
|
+
const changeOrder = comparisonOrderBy ? changeOrderClause(comparisonOrderBy, groupByDims) : void 0;
|
|
283
287
|
const orderSql = changeOrder?.orderBy ?? orderByClause(current, "");
|
|
284
288
|
const limitSql = limitOffsetClause(current);
|
|
285
289
|
const outerCurrentCols = [];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/engine",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "6.0.0",
|
|
5
5
|
"description": "Append-only Parquet/DuckDB storage engine + planner + adapters for the gscdump pipeline. Node + edge runtimes; opt-in heavy peers.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -189,10 +189,10 @@
|
|
|
189
189
|
}
|
|
190
190
|
},
|
|
191
191
|
"dependencies": {
|
|
192
|
-
"@gscdump/contracts": "^
|
|
193
|
-
"@gscdump/lakehouse": "^
|
|
192
|
+
"@gscdump/contracts": "^6.0.0",
|
|
193
|
+
"@gscdump/lakehouse": "^6.0.0",
|
|
194
194
|
"drizzle-orm": "1.0.0-rc.4",
|
|
195
|
-
"gscdump": "^
|
|
195
|
+
"gscdump": "^6.0.0",
|
|
196
196
|
"pathe": "^2.0.3",
|
|
197
197
|
"proper-lockfile": "^4.1.2"
|
|
198
198
|
},
|
|
@@ -202,6 +202,7 @@
|
|
|
202
202
|
"@types/node": "^26.6.2",
|
|
203
203
|
"@types/proper-lockfile": "^4.1.4",
|
|
204
204
|
"aws4fetch": "^1.0.20",
|
|
205
|
+
"fzstd": "^0.1.1",
|
|
205
206
|
"hyparquet": "^1.31.1",
|
|
206
207
|
"hyparquet-writer": "^0.16.10",
|
|
207
208
|
"icebird": "^0.8.30",
|