Skip to content

[codex] Harden source multi-key pushdown reducers#59

Merged
ashione merged 3 commits into
mainfrom
auto/source-typed-reducer
Jun 27, 2026
Merged

[codex] Harden source multi-key pushdown reducers#59
ashione merged 3 commits into
mainfrom
auto/source-typed-reducer

Conversation

@ashione

@ashione ashione commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add JSON multi-key source aggregate typed reducer support for COUNT, numeric SUM, and AVG behind the existing source pushdown contract.
  • Keep JSON multi-key lookup semantic-safe by using encoded-key lookup only for plain string keys and falling back to Value keys for numeric, bool, and null cases.
  • Add CSV/line selected-vs-generic benchmark guardrails so rejected shared-reducer paths do not regress back into the hot path.
  • Document and test the measured rejected candidates: JSON dictionary/packed-key lookup and line split encoded-reducer routing.

Validation

  • bazel test //:core_regression --test_output=errors
  • bazel build //:sql_demo //:df_demo //:stream_demo
  • ./scripts/run_columnar_kernel_benchmark_gate.sh
  • git diff --check
  • focused changed-file secret scan

Notes

The retained benchmark-backed win is JSON multi-key typed aggregate pushdown. CSV and line multi-key shared reducer attempts were practiced and rejected because repeated local benchmark runs did not prove stable wins; the benchmark gate now checks those paths against generic execution.

ashione added 3 commits June 21, 2026 23:29
Classify multi-key source aggregates separately and route JSON aggregate pushdown through a shared typed reducer with encoded-key lookup.

Keep CSV and line multi-key pushdown on their existing paths after local benchmarks showed the shared reducer was slower there. Extend the benchmark gate to require the JSON typed path to beat generic execution.
Keep JSON multi-key aggregation on semantic-safe encoded lookup with a single map probe and cover numeric key semantics for typed and generic reducers.

Add CSV and line selected-vs-generic benchmark guardrails, short-circuit empty compiled predicates, and document the rejected packed-key candidate.
@ashione ashione force-pushed the auto/source-typed-reducer branch from 3d439b8 to e148c6a Compare June 27, 2026 15:23
@ashione ashione marked this pull request as ready for review June 27, 2026 15:45
@ashione ashione merged commit 76b5419 into main Jun 27, 2026
4 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e148c6ab13

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +2562 to +2565
aggregate_value =
parsedScalarToValue(row_values[static_cast<std::size_t>(
access_plan.local_value_by_aggregate.front())]);
aggregate_value_ptr = &aggregate_value;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve JSON strings in typed SUM/AVG

In the JSON multi-key typed path, parsedScalarToValue re-parses quoted JSON string scalars with parseScalarCell, so a value like "10" becomes numeric and contributes to SUM/AVG. The generic JSON aggregate path uses updateAggregateStatesParsed, which only sums is_int64/is_double tokens, matching load_json_file where quoted numbers remain strings. This makes selected vs Generic pushdown return different results for multi-key JSON SUM/AVG when the aggregate column contains quoted numeric strings.

Useful? React with 👍 / 👎.

Comment on lines +57 to +59
cache->schema = table.schema;
cache->columns.resize(table.schema.fields.size());
table.columnar_cache = std::move(cache);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Initialize typed reducer Arrow format slots

When the JSON multi-key path returns typed_reducer.finalize(), this helper builds a columnar cache with columns sized but leaves arrow_formats empty. The repo's columnar invariant requires arrow_formats.size() == columns.size() in validateColumnarCache, so downstream validation or append-column paths see every typed aggregate result as an invalid columnar cache. Resize arrow_formats alongside columns here.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant