@gscdump/engine 0.25.3 → 0.25.4
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/_chunks/resolver.mjs +13 -13
- package/package.json +3 -3
|
@@ -449,10 +449,10 @@ function createIcebergResolverAdapter() {
|
|
|
449
449
|
});
|
|
450
450
|
}
|
|
451
451
|
const COMPARISON_FILTER_SQL = {
|
|
452
|
-
new: sql`AND (p.impressions
|
|
453
|
-
lost: sql`AND p.impressions > 0 AND c.impressions = 0`,
|
|
454
|
-
improving: sql`AND c.clicks > COALESCE(p.clicks, 0)`,
|
|
455
|
-
declining: sql`AND c.clicks < p.clicks AND p.clicks > 0`
|
|
452
|
+
new: sql`AND COALESCE(p.impressions, 0) = 0 AND COALESCE(c.impressions, 0) > 0`,
|
|
453
|
+
lost: sql`AND COALESCE(p.impressions, 0) > 0 AND COALESCE(c.impressions, 0) = 0`,
|
|
454
|
+
improving: sql`AND COALESCE(c.clicks, 0) > COALESCE(p.clicks, 0)`,
|
|
455
|
+
declining: sql`AND COALESCE(c.clicks, 0) < COALESCE(p.clicks, 0) AND COALESCE(p.clicks, 0) > 0`
|
|
456
456
|
};
|
|
457
457
|
function collapseWs(s) {
|
|
458
458
|
return s.replace(/\s+/g, " ").trim();
|
|
@@ -686,21 +686,21 @@ function resolveComparisonSQL(current, previous, options, comparisonFilter) {
|
|
|
686
686
|
if (groupByExprs.length > 0) previousCte = sql`${previousCte} GROUP BY ${joinComma(groupByExprs)}`;
|
|
687
687
|
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");
|
|
688
688
|
const filterClause = comparisonFilter ? COMPARISON_FILTER_SQL[comparisonFilter] : sql.raw("");
|
|
689
|
-
const orderSql = orderByClause(current, "
|
|
689
|
+
const orderSql = orderByClause(current, "");
|
|
690
690
|
const limitSql = limitOffsetClause(current);
|
|
691
691
|
const outerCurrentCols = [];
|
|
692
692
|
for (const d of groupByDims) {
|
|
693
693
|
const colName = d.replace(/\W/g, "");
|
|
694
|
-
outerCurrentCols.push(sql.raw(`c.${colName} as "${colName}"`));
|
|
694
|
+
outerCurrentCols.push(sql.raw(`COALESCE(c.${colName}, p.${colName}) as "${colName}"`));
|
|
695
695
|
}
|
|
696
|
-
outerCurrentCols.push(sql.raw("CAST(c.clicks AS DOUBLE) as \"clicks\""));
|
|
697
|
-
outerCurrentCols.push(sql.raw("CAST(c.impressions AS DOUBLE) as \"impressions\""));
|
|
698
|
-
outerCurrentCols.push(sql.raw("c.ctr as \"ctr\""));
|
|
699
|
-
outerCurrentCols.push(sql.raw("c.position as \"position\""));
|
|
700
|
-
const mainQuery = sql`WITH current AS (${currentCte}), previous AS (${previousCte}) SELECT ${joinComma(outerCurrentCols)}, COALESCE(CAST(p.clicks AS DOUBLE), 0) as "prevClicks", COALESCE(CAST(p.impressions AS DOUBLE), 0) as "prevImpressions", COALESCE(p.ctr, 0) as "prevCtr", COALESCE(p.position, 0) as "prevPosition" FROM current c
|
|
696
|
+
outerCurrentCols.push(sql.raw("CAST(COALESCE(c.clicks, 0) AS DOUBLE) as \"clicks\""));
|
|
697
|
+
outerCurrentCols.push(sql.raw("CAST(COALESCE(c.impressions, 0) AS DOUBLE) as \"impressions\""));
|
|
698
|
+
outerCurrentCols.push(sql.raw("COALESCE(c.ctr, 0) as \"ctr\""));
|
|
699
|
+
outerCurrentCols.push(sql.raw("COALESCE(c.position, 0) as \"position\""));
|
|
700
|
+
const mainQuery = sql`WITH current AS (${currentCte}), previous AS (${previousCte}) SELECT ${joinComma(outerCurrentCols)}, COALESCE(CAST(p.clicks AS DOUBLE), 0) as "prevClicks", COALESCE(CAST(p.impressions AS DOUBLE), 0) as "prevImpressions", COALESCE(p.ctr, 0) as "prevCtr", COALESCE(p.position, 0) as "prevPosition" FROM current c FULL OUTER JOIN previous p ON ${joinOn} WHERE 1=1 ${filterClause} ${orderSql} ${limitSql}`;
|
|
701
701
|
const firstGroupBy = groupByDims[0] ? groupByDims[0].replace(/\W/g, "") : "clicks";
|
|
702
|
-
const countInnerSelect = sql.raw(`c.${firstGroupBy}`);
|
|
703
|
-
const countQuery = sql`WITH current AS (${currentCte}), previous AS (${previousCte}) SELECT COUNT(*) as total FROM (SELECT ${countInnerSelect} FROM current c
|
|
702
|
+
const countInnerSelect = groupByDims[0] ? sql.raw(`COALESCE(c.${firstGroupBy}, p.${firstGroupBy})`) : sql.raw(`c.${firstGroupBy}`);
|
|
703
|
+
const countQuery = sql`WITH current AS (${currentCte}), previous AS (${previousCte}) SELECT COUNT(*) as total FROM (SELECT ${countInnerSelect} FROM current c FULL OUTER JOIN previous p ON ${joinOn} WHERE 1=1 ${filterClause})`;
|
|
704
704
|
const main = compileCollapsed(adapter, mainQuery);
|
|
705
705
|
const count = compileCollapsed(adapter, countQuery);
|
|
706
706
|
return {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/engine",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.25.
|
|
4
|
+
"version": "0.25.4",
|
|
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",
|
|
@@ -185,8 +185,8 @@
|
|
|
185
185
|
"drizzle-orm": "1.0.0-rc.3",
|
|
186
186
|
"icebird": "^0.8.6",
|
|
187
187
|
"proper-lockfile": "^4.1.2",
|
|
188
|
-
"
|
|
189
|
-
"gscdump": "0.25.
|
|
188
|
+
"gscdump": "0.25.4",
|
|
189
|
+
"@gscdump/contracts": "0.25.4"
|
|
190
190
|
},
|
|
191
191
|
"devDependencies": {
|
|
192
192
|
"@duckdb/duckdb-wasm": "^1.32.0",
|