Skip to content

driver-memory's AnalyticsResult.sql loses a RegExp operand to {}, so the pipeline dump shows no pattern at all #7853

Description

@huangyiirene

Found while implementing #7117 (the analytics generateSql() echo). Out of that card's scope — it is a different exit with a different failure mode — so it is filed rather than folded in. #7117's PR declares its status in the per-face table.

Measured on origin/main @ 69fde55, executed

MemoryAnalyticsService.query() returns AnalyticsResult.sql from generateSqlFromPipeline() (memory-analytics.ts), which dumps the executed mingo pipeline stage by stage:

const stages = pipeline.map((stage, idx) => {
  const op = Object.keys(stage)[0];
  return `/* Stage ${idx + 1}: ${op} */ ${JSON.stringify(stage[op])}`;
}).join('\n');

For {name: {$contains: 'Industries'}} on a one-row cube that prints:

-- MongoDB Aggregation Pipeline on table: deal
/* Stage 1: $match */ {"name":{"$regex":{}}}
/* Stage 2: $group */ {"_id":{"id":"$id"},"total":{"$sum":1}}
/* Stage 3: $project */ {"_id":0,"id":"$_id.id","total":"$total"}

JSON.stringify renders a RegExp as {} — it has no own enumerable properties — so the pattern is gone. The $match stage is reported as constraining name by an empty object. Every operator whose predicate carries a RegExp is affected: contains, icontains, notContains (the last nested inside $not).

Why this is filed separately from #7117, and at a lower grade

#7117 is the #5333 class — a rendering that contradicts execution. This is not that:

So the direction is lost-information on a transparency surface, not a wrong answer. It is still worth closing: this string is the only thing an author debugging an in-memory chart is given, and the one field it drops is the one they are usually looking for.

Scope

generateSqlFromPipeline() in packages/drivers/driver-memory/src/memory-analytics.ts. A replacer that renders a RegExp as its source / flags would be the smallest fix; whether the dump should render $regex in the pattern's own syntax (/Industries/) or as {"$regex":"Industries"} is the one decision to make.

A check should assert on the dump's content for a pattern operator, not merely that the string is non-empty — the current output is non-empty and passes any such assertion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions