@gscdump/engine 0.31.5 → 0.31.6
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/rollups.mjs +47 -30
- package/package.json +3 -3
package/dist/rollups.mjs
CHANGED
|
@@ -603,44 +603,61 @@ const queryCanonicalVariantsRollup = {
|
|
|
603
603
|
});
|
|
604
604
|
if (parts.length === 0) return [];
|
|
605
605
|
const partitions = parts.map((p) => p.partition);
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
606
|
+
const byCanonical = /* @__PURE__ */ new Map();
|
|
607
|
+
let cursor = null;
|
|
608
|
+
for (;;) {
|
|
609
|
+
const after = cursor === null ? "" : `AND query > '${cursor.replace(/'/g, "''")}'`;
|
|
610
|
+
const { rows } = await engine.runSQL({
|
|
611
|
+
ctx,
|
|
612
612
|
table: "queries",
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
613
|
+
...searchType !== void 0 ? { searchType } : {},
|
|
614
|
+
fileSets: { FILES: {
|
|
615
|
+
table: "queries",
|
|
616
|
+
partitions
|
|
617
|
+
} },
|
|
618
|
+
sql: `
|
|
619
619
|
SELECT
|
|
620
620
|
COALESCE(NULLIF(query_canonical, ''), query) AS joinKey,
|
|
621
621
|
query AS query,
|
|
622
622
|
SUM(clicks) AS clicks,
|
|
623
623
|
SUM(impressions) AS impressions,
|
|
624
|
-
SUM(sum_position) AS sum_pos
|
|
625
|
-
ROW_NUMBER() OVER (PARTITION BY COALESCE(NULLIF(query_canonical, ''), query) ORDER BY SUM(clicks) DESC) AS rn,
|
|
626
|
-
COUNT(*) OVER (PARTITION BY COALESCE(NULLIF(query_canonical, ''), query)) AS variantCount
|
|
624
|
+
SUM(sum_position) AS sum_pos
|
|
627
625
|
FROM read_parquet({{FILES}}, union_by_name = true)
|
|
626
|
+
WHERE query IS NOT NULL ${after}
|
|
628
627
|
GROUP BY COALESCE(NULLIF(query_canonical, ''), query), query
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
628
|
+
ORDER BY query
|
|
629
|
+
LIMIT ${ROLLUP_PAGE_ROWS_WIDE}
|
|
630
|
+
`
|
|
631
|
+
});
|
|
632
|
+
for (const r of rows) {
|
|
633
|
+
const joinKey = String(r.joinKey);
|
|
634
|
+
const list = byCanonical.get(joinKey);
|
|
635
|
+
const v = {
|
|
636
|
+
query: String(r.query),
|
|
637
|
+
clicks: Number(r.clicks),
|
|
638
|
+
impressions: Number(r.impressions),
|
|
639
|
+
sumPos: Number(r.sum_pos)
|
|
640
|
+
};
|
|
641
|
+
if (list) list.push(v);
|
|
642
|
+
else byCanonical.set(joinKey, [v]);
|
|
643
|
+
}
|
|
644
|
+
if (rows.length < 2e4) break;
|
|
645
|
+
cursor = String(rows[rows.length - 1].query);
|
|
646
|
+
}
|
|
647
|
+
const out = [];
|
|
648
|
+
for (const [joinKey, variants] of byCanonical) {
|
|
649
|
+
variants.sort((a, b) => b.clicks - a.clicks || a.query.localeCompare(b.query));
|
|
650
|
+
const canonicalName = variants[0]?.query ?? null;
|
|
651
|
+
const top = variants.slice(0, 10).filter((v) => v.impressions > 0);
|
|
652
|
+
const variantsStr = top.length === 0 ? null : top.map((v) => `${v.query}:::${v.clicks}:::${v.impressions}:::${(v.sumPos / v.impressions + 1).toFixed(1)}`).join("||");
|
|
653
|
+
out.push({
|
|
654
|
+
joinKey,
|
|
655
|
+
variantCount: BigInt(variants.length),
|
|
656
|
+
canonicalName,
|
|
657
|
+
variants: variantsStr
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
return out;
|
|
644
661
|
}
|
|
645
662
|
};
|
|
646
663
|
const queryCanonicalDailyRollup = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/engine",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.31.
|
|
4
|
+
"version": "0.31.6",
|
|
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",
|
|
@@ -181,8 +181,8 @@
|
|
|
181
181
|
"dependencies": {
|
|
182
182
|
"drizzle-orm": "1.0.0-rc.3",
|
|
183
183
|
"proper-lockfile": "^4.1.2",
|
|
184
|
-
"gscdump": "0.31.
|
|
185
|
-
"@gscdump/contracts": "0.31.
|
|
184
|
+
"gscdump": "0.31.6",
|
|
185
|
+
"@gscdump/contracts": "0.31.6"
|
|
186
186
|
},
|
|
187
187
|
"devDependencies": {
|
|
188
188
|
"@duckdb/duckdb-wasm": "^1.32.0",
|