Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Subquery is not supported in the select list. #36298

Open
2 of 3 tasks
Jinxv1007 opened this issue Jun 14, 2024 · 0 comments
Open
2 of 3 tasks

[Bug] Subquery is not supported in the select list. #36298

Jinxv1007 opened this issue Jun 14, 2024 · 0 comments

Comments

@Jinxv1007
Copy link

Search before asking

  • I had searched in the issues and found no similar issues.

Version

2.1.3

What's Wrong?

执行这条sql返回正常
SELECT
sg1.student_id,
sg1.student_name,
sg1.SUBJECT,
sg1.grade,
( SELECT COUNT() FROM student_grades sg2 WHERE sg2.SUBJECT = sg1.SUBJECT AND (sg2.grade = sg1.grade) ) + 1 AS rank
FROM
student_grades sg1
ORDER BY
sg1.SUBJECT,
rank;
但是把sg2.grade = sg1.grade 换成 sg2.grade > sg1.grade就提示Subquery is not supported in the select list.
SELECT
sg1.student_id,
sg1.student_name,
sg1.SUBJECT,
sg1.grade,
( SELECT COUNT(
) FROM student_grades sg2 WHERE sg2.SUBJECT = sg1.SUBJECT AND (sg2.grade > sg1.grade) ) + 1 AS rank
FROM
student_grades sg1
ORDER BY
sg1.SUBJECT,
rank;

What You Expected?

希望这条语句能正常执行
SELECT
sg1.student_id,
sg1.student_name,
sg1.SUBJECT,
sg1.grade,
( SELECT COUNT(*) FROM student_grades sg2 WHERE sg2.SUBJECT = sg1.SUBJECT AND (sg2.grade > sg1.grade) ) + 1 AS rank
FROM
student_grades sg1
ORDER BY
sg1.SUBJECT,
rank;

How to Reproduce?

CREATE TABLE student_grades (
student_id INT NULL,
student_name VARCHAR(50) NULL,
subject VARCHAR(50) NULL,
grade DECIMAL(5, 2) NULL
) ENGINE=OLAP
AGGREGATE KEY(student_id, student_name, subject, grade)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(student_id) BUCKETS 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"min_load_replica_num" = "-1",
"is_being_synced" = "false",
"storage_medium" = "hdd",
"storage_format" = "V2",
"inverted_index_storage_format" = "V1",
"light_schema_change" = "true",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false",
"group_commit_interval_ms" = "10000",
"group_commit_data_bytes" = "134217728"
);
INSERT INTO student_grades (student_id, student_name, subject, grade) VALUES
(1, 'Alice', 'Math', 85.00),
(2, 'Bob', 'Math', 90.00),
(3, 'Charlie', 'Math', 78.50),
(4, 'David', 'Math', 88.00),
(5, 'Eve', 'Math', 92.00),
(6, 'Frank', 'Math', 74.00),
(7, 'Grace', 'Math', 80.00),
(8, 'Heidi', 'Math', 89.50),
(9, 'Ivan', 'Math', 81.00),
(10, 'Judy', 'Math', 85.50),

(11, 'Alice', 'English', 91.00),
(12, 'Bob', 'English', 88.00),
(13, 'Charlie', 'English', 83.50),
(14, 'David', 'English', 86.00),
(15, 'Eve', 'English', 95.00),
(16, 'Frank', 'English', 78.00),
(17, 'Grace', 'English', 84.00),
(18, 'Heidi', 'English', 89.00),
(19, 'Ivan', 'English', 90.00),
(20, 'Judy', 'English', 92.00),

(21, 'Alice', 'Science', 88.00),
(22, 'Bob', 'Science', 91.00),
(23, 'Charlie', 'Science', 85.00),
(24, 'David', 'Science', 87.50),
(25, 'Eve', 'Science', 90.00),
(26, 'Frank', 'Science', 82.00),
(27, 'Grace', 'Science', 86.00),
(28, 'Heidi', 'Science', 89.50),
(29, 'Ivan', 'Science', 84.00),
(30, 'Judy', 'Science', 87.00);

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant