Dmitry Lychagin has uploaded a new change for review. https://asterix-gerrit.ics.uci.edu/2759
Change subject: [ASTERIXDB-2411][COMP] Error when aggregate inside between operator ...................................................................... [ASTERIXDB-2411][COMP] Error when aggregate inside between operator - user model changes: no - storage format changes: no - interface changes: no Details: - OperatorExpressionVisitor must copy target expression when processing between operator Change-Id: I0839e4ce89da524050ce30542fc8788963c4cbe7 --- A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2411/issue2411.1.ddl.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2411/issue2411.2.update.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2411/issue2411.3.query.sqlpp A asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/issue2411/issue2411.3.adm M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml M asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java 6 files changed, 90 insertions(+), 1 deletion(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/59/2759/1 diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2411/issue2411.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2411/issue2411.1.ddl.sqlpp new file mode 100644 index 0000000..a50d20b --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2411/issue2411.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; diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2411/issue2411.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2411/issue2411.2.update.sqlpp new file mode 100644 index 0000000..ec72ef5 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2411/issue2411.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 diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2411/issue2411.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2411/issue2411.3.query.sqlpp new file mode 100644 index 0000000..4658bb6 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/aggregate-sql/issue2411/issue2411.3.query.sqlpp @@ -0,0 +1,24 @@ +/* + * 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 value c_b from t1 +group by c_b +having count(c_d) between 2 and 4 \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/issue2411/issue2411.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/issue2411/issue2411.3.adm new file mode 100644 index 0000000..f32a580 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/aggregate-sql/issue2411/issue2411.3.adm @@ -0,0 +1 @@ +true \ No newline at end of file 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 62659ca..1465de3 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml @@ -692,6 +692,11 @@ </compilation-unit> </test-case> <test-case FilePath="aggregate-sql"> + <compilation-unit name="issue2411"> + <output-dir compare="Text">issue2411</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> diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java index f29dbf1..372f0fa 100644 --- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java +++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java @@ -37,6 +37,7 @@ import org.apache.asterix.lang.common.struct.OperatorType; import org.apache.asterix.lang.common.struct.QuantifiedPair; import org.apache.asterix.lang.sqlpp.util.FunctionMapUtil; +import org.apache.asterix.lang.sqlpp.util.SqlppRewriteUtil; import org.apache.asterix.lang.sqlpp.visitor.base.AbstractSqlppExpressionScopingVisitor; import org.apache.asterix.om.functions.BuiltinFunctions; import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionAnnotation; @@ -139,8 +140,9 @@ Expression leftComparison = createLessThanExpression(left, target, operatorExpr.getHints(), operatorExpr.getSourceLocation()); // Creates the expression target <= right. + Expression targetCopy = (Expression) SqlppRewriteUtil.deepCopy(target); Expression rightComparison = - createLessThanExpression(target, right, operatorExpr.getHints(), operatorExpr.getSourceLocation()); + createLessThanExpression(targetCopy, right, operatorExpr.getHints(), operatorExpr.getSourceLocation()); OperatorExpr andExpr = new OperatorExpr(); andExpr.addOperand(leftComparison); andExpr.addOperand(rightComparison); -- To view, visit https://asterix-gerrit.ics.uci.edu/2759 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0839e4ce89da524050ce30542fc8788963c4cbe7 Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Dmitry Lychagin <dmitry.lycha...@couchbase.com>