Skip to content

fix(explain): port EXPLAIN FORMAT=JSON to IndexSearchScan (#30108) - #30110

Closed
cpegeric wants to merge 1 commit into
matrixorigin:mainfrom
cpegeric:fix_sql_json_index_search_scan
Closed

cpegeric wants to merge 1 commit into
matrixorigin:mainfrom
cpegeric:fix_sql_json_index_search_scan

Conversation

@cpegeric

@cpegeric cpegeric commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • Bug fix

Which issue(s) this PR fixes:

Fixes #30108

Related: #28301 (EXPLAIN FORMAT=JSON, #28435)

What this PR does / why we need it:

Main does not compile. #28435 (EXPLAIN FORMAT=JSON, #28301) was written against the plan API before #29746 and merged after it. #29746 removed Node_VECTOR_INDEX_SCAN and plan.VectorIndexScan in favour of Node_INDEX_SEARCH_SCAN / plan.IndexSearchScan. It also moved the ivfflat-only fields InitialProbeCount, BucketExpandStep, ThreadsSearch and FirstRoundLimit into per-algorithm algo_options / algo_exprs. pkg/sql/plan/explain/sql_json.go and its test still use the removed names. Each PR passed CI on its own head, but the combination was never built.

This ports the JSON description of an index search scan to plan.IndexSearchScan:

  • Algorithm settings: the keys of the algo_options JSON object, in key order. ivfflat keeps initial_probe_count, bucket_expand_step and threads_search under the same names, and hnsw, cagra and ivfpq report their own options.
  • Algorithm expressions: named by algo_expr_names, so ivfflat keeps first_round_limit. A name/expression count mismatch, or algo_options that is not a JSON object, is an error.
  • query_payload replaces query_vector, because the payload is a vector, or text for fulltext.
  • algo= names the index algorithm.

No VectorIndexScan / VECTOR_INDEX_SCAN reference remains in .go or .proto files; the pb was already clean.

Tests

  • pkg/sql/plan/explain: the vector fixtures are moved to IndexSearchScan, including algo_options ordering, named algo_exprs, and the two new error paths. The package passes.
  • BVT optimizer/explain_format_json.sql: 68/68. The two vector-scan regexes now match query_payload=.
  • BVT cases/optimizer: 1696 passed, 0 failed, 4 ignored.
  • Clean GPU build of mo-service.

🤖 Generated with Claude Code

…in#28301)

matrixorigin#28435 added EXPLAIN FORMAT=JSON against the pre-matrixorigin#29746 plan API; it merged after
matrixorigin#29746 removed Node_VECTOR_INDEX_SCAN and plan.VectorIndexScan, so main does not
compile. The JSON vector-scan description now reads plan.IndexSearchScan:

- algorithm settings are the keys of algo_options in key order, so ivfflat keeps
  initial_probe_count / bucket_expand_step / threads_search, and other algorithms
  report their own options;
- algorithm expressions are named by algo_expr_names (ivfflat first_round_limit);
- the query is query_payload (a vector or fulltext text), and algo= names the index
  algorithm.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added the kind/bug Something isn't working label Oct 13, 2026
@cpegeric cpegeric changed the title fix(explain): port EXPLAIN FORMAT=JSON to IndexSearchScan (#28301) fix(explain): port EXPLAIN FORMAT=JSON to IndexSearchScan (#30108) Oct 13, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Oct 13, 2026
@cpegeric cpegeric closed this Oct 13, 2026
XuPeng-SH pushed a commit that referenced this pull request Oct 14, 2026
## What type of PR is this?

- [x] Test and CI

## Which issue(s) this PR fixes:

Related to #30045. This regression-only PR does not automatically close
the original deployment issue.

## What this PR does / why we need it:

The original three-column view (`INT`, `VARCHAR(8)`, `DECIMAL(24,6)`)
exposed stock SQLAlchemy reflection failures when DESCRIBE returned
uppercase, width-bearing type strings. The production fix is already
merged in
[#29893](#29893), merge
`f42af4dfcba210fd91b6f1fc5d7b5a72704502ee`. This PR records the scalar
reproduction independently of BOOL aliases.

The canonical BVT checks table/view DESCRIBE, view SHOW COLUMNS and
ordered information_schema type/nullability values (`int`, `varchar(8)`,
`decimal(24,6)`). The stock MySQL/PyMySQL Inspector test checks
table/view names, types, width, precision/scale, nullability/defaults
and absence of NullType or SAWarning, with committed setup and finally
cleanup. The shared fixture uses `sa.engine.URL.create` and
`future=True` so its existing commit/rollback calls work across
SQLAlchemy 1.4 and 2.x. Existing BOOL, ENUM/SET, prepared metadata,
restore and teardown cases remain intact. No production behavior
changes.

Integration and execution identity:
- Normal main merge preserves the original PR history. Tested base:
`5d971d07a7c5a52a71f2c10390b109cebf5c0825`; current test head:
`e412b88e94940c352334d2d034a4fb22ee106ebc`.
- Both actual merged prerequisites are ancestors: #29893 above, then
[#30111](#30111), merge
`f14a1fa9ee813529b7bde89ecc74dddca420dc00`, which repairs the former
EXPLAIN/protobuf build break. Closed/unmerged #30110 is not a
prerequisite.
- Formal `make build-with-prebuilt-native` PASS with Go 1.27.1, CGo
enabled and verified owned CPU native provenance. Service producer is
`ef7f81acaeb3353e9ee3e62530dd6d3c8f8e83c3`, binary SHA256
`d11d383dcfeba4d188eea5a57888ded868dab634818bbd50ee4b886620a06b69`; its
successor changes only the Python fixture. No rebuilt-successor claim.
- Latest observed main `838bf5d1f8a34e09dc984b5e7d118bcbf2900ab9` is
newer than the tested base. Its row-rule metadata visibility hook
requires active rewrite rules, absent from these fresh-root fixtures.
The prepared-policy change also touches ordinary PREPARE creation and
therefore intersects the canonical fixture; latest-main runtime remains
NOT_RUN and is not inferred from this exact tested-base evidence. No
newer main merge is included.

Current validation:
- Canonical mo-tester: **64/64 statements twice**, exact result
serialization and type cell comparison; standard `nometa` ignores JDBC
field metadata. Database and snapshot teardown verified after both runs.
- Stock SQLAlchemy **2.1.4** and **1.4.54**, PyMySQL **1.2.3**: the
complete online reflection file passes **5/5 in each family**, zero
failures/errors/skips; actual imports bind to the current SDK/worktree.
The legacy-1.4 missing commit/rollback API was detected before the
fixture fix.
- Native Superset **6.1.0**, SQLAlchemy **1.4.54**: actual
CreateDatasetCommand registration, persistence, reload and
fetch_metadata PASS for the scalar view; INTEGER / VARCHAR(8) /
DECIMAL(24,6), unchanged refresh and zero SAWarning including refresh.
Its own SQLite app metadata and MO objects were cleaned. This is native
production application API execution, not the official Linux deployment.
- Both owned service groups and all Java/pytest/Superset child groups
are stopped; native loader/ISCP and terminal catalog/cleanup checks
passed.
- SQL/Python default diff whitespace check PASS. The result file
preserves three required last empty-cell separators; other whitespace
checks and actual canonical comparison PASS.
- Original build FAIL and the first wrapper's missing consumer database
FAIL are retained. The latter followed successful canonical cleanup and
is addressed by explicit consumer database admission; it is not a
product semantic failure. Older `21f19` results remain supplemental and
are not relabeled current-head evidence.

QA required: yes. Deployed BI compatibility should be checked in the
original Superset Linux image and original ten domain views; neither is
claimed by local native application validation. Those
deployment/issue-closure checks remain separate from this regression
PR's current-source review and local correctness evidence. Independent
review is complete for this regression scope; no merge or issue closure
is requested.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch had an error being deployed

1 failed deployment
ci — 43acc088 Deployed Oct 13, 2026 by cpegeric
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: EXPLAIN JSON uses retired vector scan protobuf types and breaks main build

2 participants