Skip to content

fix(mongodb): reject SET external table columns - #27271

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
iamlinjunhong:m-27259
Aug 25, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
iamlinjunhong:m-27259

Conversation

@iamlinjunhong

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #27259

What this PR does / why we need it:

fix(mongodb): reject SET external table columns

@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 →

@aunjgr aunjgr 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.

Reviewed exact head e1c31f5. SET remains distinguishable from ordinary BIGINT UNSIGNED at this boundary through T_uint64 plus nonempty member metadata; rejecting it before ColumnMapping drops Enumvalues prevents the MongoDB converter from silently treating SET as a supported integer. Regressions cover nullable and NOT NULL columns under strict and try_null conversion modes and verify failed DDL produces no plan. No blocking findings.

@mergify

mergify Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@XuPeng-SH XuPeng-SH 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.

Reviewed exact head e1c31f5894151a1fe70b13960c2348965b06953f: APPROVED.

The rejection is placed at the last boundary where SET remains distinguishable from ordinary BIGINT UNSIGNED: both use T_uint64, but only SET carries nonempty member metadata. Rejecting before ColumnMapping flattens the plan type prevents the MongoDB converter from silently accepting SET as an unsigned integer without affecting ordinary unsigned columns.

Coverage exercises nullable and NOT NULL SET columns under strict and try-null conversion modes, asserts that failed CREATE retains no DDL plan, and includes the direct mapping contract. Both focused controlled-CGo regressions pass on this exact head. I found no blocking issue in the complete three-file diff.

@mergify mergify Bot added the queued label Aug 20, 2026
@mergify

mergify Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-20 09:40 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-08-20 10:51 UTC · at 2537193639a556c04672f1cbaf0a817fce3e246e

This pull request spent 1 hour 11 minutes in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

Pull request #27271 has been dequeued

Queue conditions are not satisfied:

  • #changes-requested-reviews-by<=0

Failing checks:

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@aptend aptend 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.

[P1] Reject SET with a single empty member

Location: pkg/sql/mongodb/mapping.go:115.

Enumvalues != "" is not a complete SET discriminator. MatrixOne accepts empty SET members, and SET("") is normalized to []string{""}; strings.Join therefore stores an empty Enumvalues string on the planned T_uint64. This condition is false, so NewConverter receives a bare uint64 mapping and the unsupported SET DDL succeeds.

A planner-level reproducer on this exact head is:

CREATE EXTERNAL TABLE tpch.mongo_set_empty (
  v SET("") MONGODB_PATH "device_id"
) ENGINE=MONGODB WITH (
  "connection"="source", "database"="telemetry", "collection"="samples",
  "schema_mode"="explicit", "conversion_mode"="strict", "max_parallelism"="1"
);

A temporary regression using runOneStmt expected MongoDB mapping target type SET, but got nil error and a plan. This leaves a valid SET spelling able to bypass the fix and be silently treated as BIGINT UNSIGNED. Please identify SET from the parsed column type (which still carries the MYSQL_TYPE_SET OID/family) or otherwise preserve an unambiguous discriminator, and add the single-empty-member case to the strict/try-null coverage.

@iamlinjunhong

Copy link
Copy Markdown
Contributor Author

@aptend Fresh independent verification on exact head 679c4c7bd60b3b65440a2038646f425dab217aae: ParseTableMappingSpec rejects the parsed MYSQL_TYPE_SET OID before plan conversion flattens it to T_uint64, so SET("") cannot bypass the check while ordinary BIGINT UNSIGNED remains accepted. Controlled CGo test TestParseTableMappingSpecRejectsInvalidOptionsAndColumnContracts passes, including unsupported_single_empty_set_member; the planner regression covers non-empty/single-empty x nullable/NOT NULL x strict/try_null and asserts no DDL plan on rejection. The exact-head Actions run is fully successful: https://github.com/matrixorigin/matrixone/actions/runs/32447983297 . Please re-review this head.

@iamlinjunhong

Copy link
Copy Markdown
Contributor Author

@aptend Rechecked the current exact head 679c4c7bd60b3b65440a2038646f425dab217aae. The P1 reproducer is now closed: ParseTableMappingSpec rejects the parsed column MYSQL_TYPE_SET OID before ColumnMapping can flatten SET to T_uint64, so SET("") is rejected even when joined Enumvalues is empty; the BIGINT UNSIGNED acceptance control remains intact. The regression includes the direct single-empty-member mapping case and planner coverage for non-empty/single-empty SET × nullable/NOT NULL × strict/try_null, asserting that a rejected CREATE returns no DDL plan. The exact-head Actions run completed successfully: https://github.com/matrixorigin/matrixone/actions/runs/32447983297 . No further code change is needed; please re-review this head.

@iamlinjunhong

Copy link
Copy Markdown
Contributor Author

@aptend 本次按当前 exact head 679c4c7bd60b3b65440a2038646f425dab217aae 重新验证:ParseTableMappingSpec 在计划将 SET 扁平为 T_uint64 前依据解析列的 MYSQL_TYPE_SET OID 拒绝它,因此 SET(\"\") 不依赖 Enumvalues 是否为空,不能再被当作 BIGINT UNSIGNED。受控 CGo 命令 .agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=120s -run "^TestParseTableMappingSpecRejectsInvalidOptionsAndColumnContracts$" ./pkg/sql/mongodb 已通过,其中包含 unsupported_single_empty_set_member;该 exact-head 的全部 Actions 也已成功:https://github.com/matrixorigin/matrixone/actions/runs/32447983297 。烦请重新审阅。

@XuPeng-SH XuPeng-SH 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.

Re-reviewed exact head 679c4c7.

The new parsed-type discriminator closes the previous SET single-empty-member gap: SET('') is rejected while the AST still carries MYSQL_TYPE_SET, before both SET and ordinary BIGINT UNSIGNED flatten to T_uint64 and before empty Enumvalues loses provenance. The ordinary unsigned control remains accepted, and failed SET DDL retains no plan.

Validation on the exact clean worktree:

  • focused ParseTableMappingSpec regression under -race -count=10
  • focused planner SET/unsigned regressions under -count=3
  • full ./pkg/sql/mongodb package
  • git diff --check

No blocking findings.

This branch was previously deployed

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

Labels

size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants