Skip to content

evalengine: disable the static IN hash table for JSON operands - #20691

Open
GrahamCampbell wants to merge 1 commit into
vitessio:mainfrom
GrahamCampbell:evalengine-json-in-static-table
Open

evalengine: disable the static IN hash table for JSON operands#20691
GrahamCampbell wants to merge 1 commit into
vitessio:mainfrom
GrahamCampbell:evalengine-json-in-static-table

Conversation

@GrahamCampbell

@GrahamCampbell GrahamCampbell commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Description

The compiled IN fast path builds a static hash table from an all-literal list and treats a hash hit as equality without comparing the candidate. JSON values hash through their MySQL-style ordering weights, which fingerprint arrays and objects by kind and cardinality only, so any two arrays of the same length collide, as do any two objects with the same member count: with a JSON column containing [1], the compiled json_col IN (JSON_ARRAY(2)) returns 1 where the interpreter and MySQL return 0. JSON operands now stay on the slow path, which performs real comparisons. The weight strings themselves are unchanged, since their shape is intentional for ordering; the defect was treating their hash as proof of equality.

This leads the JSON chain, so the fast-path fix merges before anything widens its reach. At this position the compiler cannot yet push a constant-folded JSON literal, so an IN list over folded JSON documents fails to compile instead of building the table: it is pushed down to MySQL or evaluated by the interpreter where possible, and errors where a compiled program is required, which is the correct direction of failure; the test pins exactly that, and #20682 flips the same test to compiled evaluation once literal pushing exists.

Related Issue(s)

#20682 builds on this change.

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

Compiled IN comparisons over JSON arrays and objects no longer report false matches for same-cardinality values. Until the follow-up JSON literal change lands, IN over a list of constant-folded JSON documents does not compile: it is pushed down to MySQL or evaluated by the interpreter where possible, and errors where a compiled program is required, instead of returning wrong matches. No migrations or configuration changes.

AI Disclosure

This PR was written primarily by Fable with review from GPT 5.6 Sol.


graph LR
    subgraph json [JSON support]
        direction TB
        PR20625["#20625 (merged)<br>mysql/json: fix MarshalTo discarding accumulated output for nested blob and bit values"]
        PR20632["#20632<br>vtgate: preserve IN value lists in complex aggregate projections"]
        PRA["#20691<br>evalengine: disable the static IN hash table for JSON operands"]
        PR20682["#20682 (draft)<br>evalengine: support constant-folded JSON values as literals"]
        PR20683["#20683 (draft)<br>evalengine, sqlparser: MySQL comparison domains; nested BETWEEN parentheses"]
        PR20626["#20626 (draft)<br>vtgate: support cross-shard JSON_ARRAYAGG and JSON_OBJECTAGG"]
        PR20625 --> PR20682
        PRA --> PR20682
        PR20682 --> PR20683
        PR20632 --> PR20626
        PR20683 --> PR20626
    end

    subgraph union [Union routing]
        direction TB
        PR20628["#20628<br>vtgate: track per-source copies of pushed join predicates so merges skip them"]
        PR20629["#20629 (merged)<br>vtgate: fix None routing handling when merging unions"]
        PR20630["#20630 (draft)<br>vtgate: merge unions on join-predicate-free routings when all sources agree"]
        PR20755["#20755<br>vtgate: fix union merging through reference-table alternates"]
        PR20756["#20756 (draft)<br>vtgate: merge empty reference branches through rewritten copies"]
        PR20628 --> PR20630
        PR20629 --> PR20630
        PR20630 --> PR20756
        PR20755 --> PR20756
    end

    subgraph cte [Recursive CTEs]
        direction TB
        PR20759["#20759<br>vtgate: expand qualified stars without JOIN USING coalescing"]
        PR20633["#20633 (draft)<br>vtgate: validate the declared column list length of CTEs and derived tables"]
        PR20631["#20631 (draft)<br>vtgate: bind recursive CTE column filters as arguments in unmerged term queries"]
        PR20759 --> PR20633
        PR20633 --> PR20631
    end

    json ~~~ union ~~~ cte
Loading

Copilot AI balanced review requested due to automatic review settings July 25, 2026 11:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added this to the v25.0.0 milestone Jul 25, 2026
@vitess-bot vitess-bot Bot added NeedsWebsiteDocsUpdate What it says NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Jul 25, 2026
@vitess-bot

vitess-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@github-actions github-actions Bot added Component: Evalengine changes to the evaluation engine Component: VTGate labels Jul 25, 2026
@GrahamCampbell
GrahamCampbell marked this pull request as draft July 25, 2026 11:40
Copilot AI review requested due to automatic review settings July 25, 2026 11:48
@GrahamCampbell
GrahamCampbell force-pushed the evalengine-json-in-static-table branch from c2c2d94 to d2f7ebb Compare July 25, 2026 11:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@GrahamCampbell
GrahamCampbell force-pushed the evalengine-json-in-static-table branch 3 times, most recently from d94d246 to 101fe8f Compare July 25, 2026 13:24
Copilot AI review requested due to automatic review settings July 25, 2026 13:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@GrahamCampbell
GrahamCampbell marked this pull request as ready for review July 27, 2026 19:48
Copilot AI review requested due to automatic review settings July 27, 2026 19:48
@GrahamCampbell
GrahamCampbell force-pushed the evalengine-json-in-static-table branch from 101fe8f to ba2ec8c Compare July 27, 2026 19:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@GrahamCampbell

Copy link
Copy Markdown
Collaborator Author

@arthurschreiber This PR is now re-stacked to go in first, as you requested.

@arthurschreiber arthurschreiber added Backport to: release-23.0 Needs to be backport to release-23.0 Backport to: release-24.0 Needs to be backport to release-24.0 and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Jul 27, 2026
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.24%. Comparing base (70c7a72) to head (66c0fbd).
⚠️ Report is 514 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main   #20691       +/-   ##
===========================================
+ Coverage   69.67%   86.24%   +16.57%     
===========================================
  Files        1614       59     -1555     
  Lines      216793    15621   -201172     
===========================================
- Hits       151044    13473   -137571     
+ Misses      65749     2148    -63601     
Flag Coverage Δ
partial 86.24% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@GrahamCampbell
GrahamCampbell force-pushed the evalengine-json-in-static-table branch from 68133dc to 02bb066 Compare August 24, 2026 12:43
Copilot AI review requested due to automatic review settings August 24, 2026 12:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Signed-off-by: Graham Campbell <hello@gjcampbell.co.uk>
@GrahamCampbell
GrahamCampbell force-pushed the evalengine-json-in-static-table branch from 02bb066 to 66c0fbd Compare August 28, 2026 18:40
Copilot AI review requested due to automatic review settings August 28, 2026 18:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

Backport to: release-23.0 Needs to be backport to release-23.0 Backport to: release-24.0 Needs to be backport to release-24.0 Component: Evalengine changes to the evaluation engine Component: VTGate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants