[ASTERIXDB-2348][COMP] Incorrect result with distinct aggregate - user model changes: no - storage format changes: no - interface changes: no
Details: - Account for micro group by/distinct by operators in EnforceStructuralPropertiesRule Change-Id: I0f440046d6cdb2dc0302c5aa4c01ffacb703ee73 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2544 Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: Till Westmann <ti...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/cba9ec76 Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/cba9ec76 Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/cba9ec76 Branch: refs/heads/release-0.9.4-pre-rc Commit: cba9ec76ceaefdfe9a3eafa695f01d739bb74c18 Parents: cc9257e Author: Dmitry Lychagin <dmitry.lycha...@couchbase.com> Authored: Wed Mar 28 18:23:24 2018 -0700 Committer: Till Westmann <ti...@apache.org> Committed: Thu Mar 29 22:45:31 2018 -0700 ---------------------------------------------------------------------- .../issue2348/issue2348.1.ddl.sqlpp | 30 ++++++++++++++++++++ .../issue2348/issue2348.2.update.sqlpp | 27 ++++++++++++++++++ .../issue2348/issue2348.3.query.sqlpp | 26 +++++++++++++++++ .../aggregate-sql/issue2348/issue2348.3.adm | 3 ++ .../resources/runtimets/testsuite_sqlpp.xml | 5 ++++ .../rules/EnforceStructuralPropertiesRule.java | 14 +++++---- 6 files changed, 99 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/cba9ec76/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2348/issue2348.1.ddl.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2348/issue2348.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2348/issue2348.1.ddl.sqlpp new file mode 100644 index 0000000..a50d20b --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2348/issue2348.1.ddl.sqlpp @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +drop dataverse test if exists; +create dataverse test; + +use test; + +create type test.TestType as +{ + c_id: string +}; + +create dataset t1(TestType) primary key c_id; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/cba9ec76/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2348/issue2348.2.update.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2348/issue2348.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2348/issue2348.2.update.sqlpp new file mode 100644 index 0000000..ec72ef5 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2348/issue2348.2.update.sqlpp @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +use test; + +insert into t1 select value t from [ + {"c_id":"01","c_b":true, "c_d":900,"c_i":999999}, + {"c_id":"02","c_b":true, "c_d":800,"c_i":888888}, + {"c_id":"03","c_b":true, "c_d":700,"c_i":777777}, + {"c_id":"05","c_b":false,"c_d":111,"c_i":111111} +] t http://git-wip-us.apache.org/repos/asf/asterixdb/blob/cba9ec76/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2348/issue2348.3.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2348/issue2348.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2348/issue2348.3.query.sqlpp new file mode 100644 index 0000000..4fc8b4b --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2348/issue2348.3.query.sqlpp @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +use test; + +select min(distinct c_i) v +from t1 +where c_b +group by c_i, c_d, c_b +order by v \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/cba9ec76/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/issue2348/issue2348.3.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/issue2348/issue2348.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/issue2348/issue2348.3.adm new file mode 100644 index 0000000..cf2ede9 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/issue2348/issue2348.3.adm @@ -0,0 +1,3 @@ +{ "v": 777777 } +{ "v": 888888 } +{ "v": 999999 } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/cba9ec76/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml index 832bb06..dd2b626 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml @@ -686,6 +686,11 @@ </compilation-unit> </test-case> <test-case FilePath="aggregate-sql"> + <compilation-unit name="issue2348"> + <output-dir compare="Text">issue2348</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="aggregate-sql"> <compilation-unit name="avg_double"> <output-dir compare="Text">avg_double</output-dir> </compilation-unit> http://git-wip-us.apache.org/repos/asf/asterixdb/blob/cba9ec76/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/EnforceStructuralPropertiesRule.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/EnforceStructuralPropertiesRule.java b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/EnforceStructuralPropertiesRule.java index e8b446b..f06933a 100644 --- a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/EnforceStructuralPropertiesRule.java +++ b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/EnforceStructuralPropertiesRule.java @@ -50,14 +50,14 @@ import org.apache.hyracks.algebricks.core.algebra.operators.logical.OrderOperato import org.apache.hyracks.algebricks.core.algebra.operators.logical.OrderOperator.IOrder; import org.apache.hyracks.algebricks.core.algebra.operators.logical.OrderOperator.IOrder.OrderKind; import org.apache.hyracks.algebricks.core.algebra.operators.logical.visitors.FDsAndEquivClassesVisitor; +import org.apache.hyracks.algebricks.core.algebra.operators.physical.AbstractPreSortedDistinctByPOperator; +import org.apache.hyracks.algebricks.core.algebra.operators.physical.AbstractPreclusteredGroupByPOperator; import org.apache.hyracks.algebricks.core.algebra.operators.physical.AbstractStableSortPOperator; import org.apache.hyracks.algebricks.core.algebra.operators.physical.BroadcastExchangePOperator; import org.apache.hyracks.algebricks.core.algebra.operators.physical.ExternalGroupByPOperator; import org.apache.hyracks.algebricks.core.algebra.operators.physical.HashPartitionExchangePOperator; import org.apache.hyracks.algebricks.core.algebra.operators.physical.HashPartitionMergeExchangePOperator; import org.apache.hyracks.algebricks.core.algebra.operators.physical.InMemoryStableSortPOperator; -import org.apache.hyracks.algebricks.core.algebra.operators.physical.PreSortedDistinctByPOperator; -import org.apache.hyracks.algebricks.core.algebra.operators.physical.PreclusteredGroupByPOperator; import org.apache.hyracks.algebricks.core.algebra.operators.physical.RandomMergeExchangePOperator; import org.apache.hyracks.algebricks.core.algebra.operators.physical.RandomPartitionExchangePOperator; import org.apache.hyracks.algebricks.core.algebra.operators.physical.RangePartitionExchangePOperator; @@ -374,15 +374,17 @@ public class EnforceStructuralPropertiesRule implements IAlgebraicRewriteRule { hgbyOp.computeColumnSet(gby.getGroupByList()); break; } - case PRE_CLUSTERED_GROUP_BY: { + case PRE_CLUSTERED_GROUP_BY: + case MICRO_PRE_CLUSTERED_GROUP_BY: { GroupByOperator gby = (GroupByOperator) op; - PreclusteredGroupByPOperator preSortedGby = (PreclusteredGroupByPOperator) pOp; + AbstractPreclusteredGroupByPOperator preSortedGby = (AbstractPreclusteredGroupByPOperator) pOp; preSortedGby.setGbyColumns(gby.getGbyVarList()); break; } - case PRE_SORTED_DISTINCT_BY: { + case PRE_SORTED_DISTINCT_BY: + case MICRO_PRE_SORTED_DISTINCT_BY: { DistinctOperator d = (DistinctOperator) op; - PreSortedDistinctByPOperator preSortedDistinct = (PreSortedDistinctByPOperator) pOp; + AbstractPreSortedDistinctByPOperator preSortedDistinct = (AbstractPreSortedDistinctByPOperator) pOp; preSortedDistinct.setDistinctByColumns(d.getDistinctByVarList()); break; }