Repository navigation
Description
Description
MongoDB external-table DDL accepts GENERATED ALWAYS, but the generated expression is not evaluated during the external scan. A generated column defined as a constant is returned as NULL for every row.
Environment
- Branch:
main - Commit:
71031d0e9e45920821d71ce03f519181d346e669 - Deployment: TKE, MatrixOne
3 CN / 1 DN / 3 Log, MongoDB8.0.12three-member ReplicaSet - Namespace:
mo-search-commit-71031d0e9-20260819 - Related feature: [Feature Request]: Support MongoDB as a native external table source #26229
Steps to reproduce
With a valid MongoDB connection and a collection containing four documents, execute:
CREATE EXTERNAL TABLE ext_bad_gen (
id VARCHAR(8) MONGODB_PATH '_id',
x INT GENERATED ALWAYS AS (1) STORED
) ENGINE=MONGODB WITH (
'connection'='valid_connection',
'database'='test_db',
'collection'='events',
'schema_mode'='explicit'
);
SELECT COUNT(*), MIN(x), MAX(x) FROM ext_bad_gen;Actual behavior
The DDL succeeds. The query returns four rows, but MIN(x) and MAX(x) are both NULL; SHOW CREATE TABLE also shows a MongoDB path for the generated column.
Expected behavior
Until generated-column semantics are explicitly supported for MongoDB external tables, the DDL must be rejected atomically. If accepted in a future contract, the expression must evaluate to 1 for every row and must not be treated as a remote MongoDB field.
Stability and controls
- DDL acceptance and incorrect result reproduced 3/3.
- A normal explicit-schema MongoDB external table scans four rows with correct mapped values.
- No partial catalog object was observed after the successful but invalid definition.
Evidence
TKE terminal output and the test design report record three rounds returning 4, -999, -999 after NULL normalization.
Code analysis
The external-table schema builder appears to retain generated metadata while also assigning a MongoDB path, causing the scan to read a missing remote field instead of evaluating the generated expression; exact implementation location requires maintainer confirmation.
Regression coverage
Add a DDL regression asserting that GENERATED ALWAYS on a MongoDB external table is rejected and no mapping remains.
Related
Source feature issue: #26229.
Activity
Ariznawlll commentedon Aug 21, 2026
测试版本
main853fb9bf9b1d0ea1aa09b3cc7443ad3828ffab4a127.0.0.1:6003;MongoDB 8.0.12 ReplicaSetrs0原问题验证
配置真实 MongoDB connection,并在
test_db.events中保留 4 条源数据。连续 3 轮执行 issue 原始CREATE EXTERNAL TABLE,包含x INT GENERATED ALWAYS AS (1) STORED。每轮均返回ERROR 20105: not supported: MongoDB external table does not support generated column 'x',不再创建后返回 NULL。Happy Path 覆盖
SHOW MONGODB CONNECTIONS可见source。Unhappy Path 覆盖
mo_catalog.mo_tables中目标表数量为 0。mo_catalog.mo_mongodb_tables中目标映射数量为 0,未产生部分 catalog 状态。白盒验证
planner focused test
TestBuildMongoDBExternalTableRejectsGeneratedColumns连续 3 次通过。回归测试
已加入 MOTR PR #116,case:
14_issue_regression.issue_27348_mongodb_generated_rejection。测试证据
MOTR PR #116,提交
bc1126e5;真实 MongoDB 3 轮输出均为 20105 且 catalog 计数为 0。测试结论
测试通过。