This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new eac5d64cce0 Fix sub query ShorthandProjection missing column. (#22917)
eac5d64cce0 is described below
commit eac5d64cce0dccd9ed561c3ea2f8a031e110c086
Author: Chuxin Chen <[email protected]>
AuthorDate: Sat Dec 17 07:44:35 2022 +0800
Fix sub query ShorthandProjection missing column. (#22917)
---
.../segment/select/projection/engine/ProjectionEngine.java | 9 ++++-----
.../src/test/resources/cases/dql/dql-integration-test-cases.xml | 4 ++++
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/engine/ProjectionEngine.java
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/engine/ProjectionEngine.java
index f05fc85d0cc..3502a61cc7a 100644
---
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/engine/ProjectionEngine.java
+++
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/projection/engine/ProjectionEngine.java
@@ -23,6 +23,7 @@ import
org.apache.shardingsphere.infra.binder.segment.select.projection.Projecti
import
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.AggregationDistinctProjection;
import
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.AggregationProjection;
import
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.ColumnProjection;
+import
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.DerivedProjection;
import
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.ExpressionProjection;
import
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.ParameterMarkerProjection;
import
org.apache.shardingsphere.infra.binder.segment.select.projection.impl.ShorthandProjection;
@@ -218,12 +219,10 @@ public final class ProjectionEngine {
private Collection<Projection> getActualProjections(final
Collection<Projection> projections) {
Collection<Projection> result = new LinkedList<>();
for (Projection each : projections) {
- if (each instanceof ColumnProjection) {
- result.add(each);
- } else if (each instanceof ExpressionProjection) {
- result.add(each);
- } else if (each instanceof ShorthandProjection) {
+ if (each instanceof ShorthandProjection) {
result.addAll(((ShorthandProjection)
each).getActualColumns().values());
+ } else if (!(each instanceof DerivedProjection)) {
+ result.add(each);
}
}
return result;
diff --git
a/test/e2e/suite/src/test/resources/cases/dql/dql-integration-test-cases.xml
b/test/e2e/suite/src/test/resources/cases/dql/dql-integration-test-cases.xml
index d372041739e..1bd1d765893 100644
--- a/test/e2e/suite/src/test/resources/cases/dql/dql-integration-test-cases.xml
+++ b/test/e2e/suite/src/test/resources/cases/dql/dql-integration-test-cases.xml
@@ -1174,4 +1174,8 @@
<test-case sql="SELECT * FROM t_order o INNER JOIN t_order_item i ON
o.order_id = i.order_id ORDER BY o.order_id ASC NULLS LAST, i.item_id DESC"
db-types="PostgreSQL,openGauss,Oracle" scenario-types="db">
<assertion expected-data-source-name="read_dataset" />
</test-case>
+
+ <test-case sql="SELECT * FROM (SELECT count(*) as count, id from
t_single_table group by id) as temp_table" db-types="MySQL" scenario-types="db">
+ <assertion expected-data-source-name="read_dataset" />
+ </test-case>
</integration-test-cases>