You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: mo does not support aggregation with non-equality conditions in subqueries with predicates. #23942
CREATE TABLE ms_t_stk_sis ( SITXDT varchar(24) DEFAULT NULL COMMENT 'Trading date. Format: DDMONYYYY:HH:MI:SS (e.g. 02JAN2025:00:00:00).', SISTKC varchar(10) DEFAULT NULL COMMENT 'HKEX stock code (e.g. 00001, 00005).', SISTKN varchar(100) DEFAULT NULL COMMENT 'Stock name / company name in English.', SIHIGH decimal(16,4) DEFAULT NULL COMMENT 'Highest traded price of the day (HKD).', SILOW decimal(16,4) DEFAULT NULL COMMENT 'Lowest traded price of the day (HKD).', SICLSE decimal(16,4) DEFAULT NULL COMMENT 'Closing price of the day (HKD).', SIVOL bigint DEFAULT NULL COMMENT 'Trading volume in number of shares traded.'
);
INSERT INTO ms_t_stk_sis (SITXDT, SISTKC, SISTKN, SIHIGH, SILOW, SICLSE, SIVOL) VALUES ('02JAN2025:00:00:00', '01870', 'ACME INTL HLDGS', 1.8400, 1.7600, 1.8400, 1395000), ('02JAN2025:00:00:00', '01871', 'CHINA ORIENTED', NULL, NULL, 0.1990, 0), ('02JAN2025:00:00:00', '01872', 'GUAN CHAO HLDGS', 1.2400, 1.0100, 1.0600, 230500);
SELECT s.SISTKC,
(SELECT AVG(s2.SIVOL)
FROM ms_t_stk_sis s2
WHERE s2.SISTKC = s.SISTKC
AND STR_TO_DATE(s2.SITXDT, '%d%b%Y:%H:%i:%s') < STR_TO_DATE(s.SITXDT, '%d%b%Y:%H:%i:%s')
AND STR_TO_DATE(s2.SITXDT, '%d%b%Y:%H:%i:%s') >= STR_TO_DATE(s.SITXDT, '%d%b%Y:%H:%i:%s') - INTERVAL 30 DAY
) AS avg_30d_vol
FROM ms_t_stk_sis s;
Verified on current main (commit 1a29e67, mo-service build commit 1a29e67). The SQL from the issue now runs successfully and returns the expected result: three rows with avg_30d_vol = NULL for SISTKC 01870, 01871, and 01872. I also confirmed the related fix is present: 89f1e23 / PR #24053, which adds support for scalar aggregate subqueries with non-equality correlated predicates. I tried to run go test ./pkg/sql/plan -run TestSubQuery -count=1 as an additional check, but this local environment cannot compile pkg/sql/plan because CGO headers usearch.h and xxhash.h are missing, so that test was blocked by environment setup rather than a case failure. Based on the direct SQL verification, this issue is fixed on current main.
Activity
fix: support aggregation with non-equality conditions in scalar subqu…
fix: support aggregation with non-equality conditions in scalar subqu…
ck89119 commentedon Apr 8, 2026
fixed
Ariznawlll commentedon Apr 30, 2026
Verified on current main (commit 1a29e67, mo-service build commit 1a29e67). The SQL from the issue now runs successfully and returns the expected result: three rows with avg_30d_vol = NULL for SISTKC 01870, 01871, and 01872. I also confirmed the related fix is present: 89f1e23 / PR #24053, which adds support for scalar aggregate subqueries with non-equality correlated predicates. I tried to run go test ./pkg/sql/plan -run TestSubQuery -count=1 as an additional check, but this local environment cannot compile pkg/sql/plan because CGO headers usearch.h and xxhash.h are missing, so that test was blocked by environment setup rather than a case failure. Based on the direct SQL verification, this issue is fixed on current main.
Ariznawlll commentedon Apr 30, 2026
查询返回: