Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues and pull requests.
Branch Name
main
Commit ID
Other Environment Information
- MatrixOne: local single-CN deployment built from the commit above
- Client: mysql CLI
- Verification: 3 independent rounds
Actual Behavior
CREATE TABLE ... AS SELECT can materialize BIT_AND, BIT_OR, and BIT_XOR when the query has no grouping. The same aggregates fail during CTAS materialization as soon as the query has GROUP BY:
ERROR 3819 (HY000): constraint violation: Column 'a' cannot be null
ERROR 3819 (HY000): constraint violation: Column 'o' cannot be null
ERROR 3819 (HY000): constraint violation: Column 'x' cannot be null
The source groups contain non-NULL values, and the grouped SELECT itself returns the correct non-NULL aggregate values. A grouped VIEW over the same expressions also works. The failure therefore occurs specifically while CTAS materializes the grouped aggregate output.
The behavior is the same for numeric, BINARY, and VARBINARY operands. It is not limited to an all-NULL group.
Expected Behavior
Grouped CTAS should materialize the same values returned by the grouped SELECT. BIT_AND, BIT_OR, and BIT_XOR are non-NULL-producing aggregates and already have executable CTAS defaults.
Steps to Reproduce
DROP DATABASE IF EXISTS bitwise_grouped_ctas_repro;
CREATE DATABASE bitwise_grouped_ctas_repro;
USE bitwise_grouped_ctas_repro;
CREATE TABLE src(g INT, i INT);
INSERT INTO src VALUES (1,15),(1,51),(2,NULL);
-- Control: succeeds and returns (1,3,63,60) and the neutral values for group 2.
SELECT g, BIT_AND(i) a, BIT_OR(i) o, BIT_XOR(i) x
FROM src GROUP BY g ORDER BY g;
-- Control: ungrouped CTAS succeeds.
CREATE TABLE ungrouped AS
SELECT BIT_AND(i) a, BIT_OR(i) o, BIT_XOR(i) x FROM src;
-- Each statement below fails with ERROR 3819.
CREATE TABLE grouped_and AS SELECT g, BIT_AND(i) a FROM src GROUP BY g;
CREATE TABLE grouped_or AS SELECT g, BIT_OR(i) o FROM src GROUP BY g;
CREATE TABLE grouped_xor AS SELECT g, BIT_XOR(i) x FROM src GROUP BY g;
SELECT 1 AS recovered;
SHOW TABLES;Stability, controls, and recovery
- Reproduced 3/3 on the commit above.
- The same grouped
SELECTand groupedVIEWreturn correct values. - Ungrouped CTAS with all three bitwise aggregates succeeds and creates
BIGINT UNSIGNED NOT NULL DEFAULT 0columns. - All three grouped CTAS statements fail independently, including with only non-NULL source rows.
- Numeric,
BINARY, andVARBINARYoperands reproduce the same failure. - Failed CTAS statements leave no partial tables; the same connection remains usable.
Related work
- [Bug]: tracker for remaining CTAS schema inconsistencies with MySQL #24436 tracks broader CTAS schema compatibility. Its bitwise-aggregate subcase was reported fixed by fix(plan): align non-null aggregate CTAS defaults #27865 for ungrouped CTAS.
- fix(plan): align non-null aggregate CTAS defaults #27865 marked these aggregates as non-NULL-producing and added executable CTAS defaults, but its distributed CTAS case does not include
GROUP BY.
This report is for a value-materialization failure on the grouped execution path, not another metadata-only compatibility difference.
Suggested regression placement
Extend test/distributed/cases/ddl/create_table_as_select.sql with grouped BIT_AND, BIT_OR, and BIT_XOR CTAS cases, including an all-NULL group and binary-string operands.
Activity
fix: clear grouped BIT aggregate result null bitmap (#29360)
Ariznawlll commentedon Sep 27, 2026
测试版本
main5be6cd90b501da225be591ffffe6000bf01f515e原问题验证
在上述最新 main 上按 issue 原始复现步骤执行,并独立重复 3 次;3/3 均满足修复后的预期。当前 main 已包含修复提交
9875c6c4b4fb03421dc5e695fb378972f96eb790。Happy Path 覆盖
Unhappy Path 覆盖
白盒验证
确认修复提交
9875c6c4b4fb03421dc5e695fb378972f96eb790是当前 main 的祖先,并核对对应 MatrixOne BVT/实现路径;本次另以公开 SQL 协议执行黑盒验收。回归测试
已加入 MOTR PR #204 的
issue_29323_29325_29327_29328_29329_29330_29331_sql_contracts.test,MOTR 提交2b4462f2;本地基线比对连续 3 次通过。测试证据
5be6cd90b501da225be591ffffe6000bf01f515e测试结论
测试通过。