Repository: asterixdb Updated Branches: refs/heads/master 42f17d2ba -> 71afb3d03
[ASTERIXDB-2446][COMP] Detect duplicate field names in select clause - user model changes: no - storage format changes: no - interface changes: no Details: - Throw compile-time error if select clause has duplicate projection names Change-Id: Idd97c2edd6b4a627ad1a0225d95c26915d4ad5f7 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2951 Sonar-Qube: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> Integration-Tests: Jenkins <[email protected]> Reviewed-by: Till Westmann <[email protected]> Contrib: Till Westmann <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/3a684694 Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/3a684694 Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/3a684694 Branch: refs/heads/master Commit: 3a6846942cde2f6e97ab53e01e14a7025ca04814 Parents: 95f508b Author: Dmitry Lychagin <[email protected]> Authored: Fri Aug 31 14:21:43 2018 -0700 Committer: Till Westmann <[email protected]> Committed: Fri Aug 31 21:46:41 2018 -0700 ---------------------------------------------------------------------- .../SqlppExpressionToPlanTranslator.java | 72 +++++++++++++------- .../query-ASTERIXDB-2446-2.01.ddl.sqlpp | 30 ++++++++ .../query-ASTERIXDB-2446-2.02.update.sqlpp | 22 ++++++ .../query-ASTERIXDB-2446-2.03.query.sqlpp | 28 ++++++++ .../query-ASTERIXDB-2446-2.04.query.sqlpp | 28 ++++++++ .../query-ASTERIXDB-2446-2.05.query.sqlpp | 29 ++++++++ .../query-ASTERIXDB-2446-2.06.query.sqlpp | 28 ++++++++ .../query-ASTERIXDB-2446-2.07.query.sqlpp | 29 ++++++++ .../query-ASTERIXDB-2446-2.08.query.sqlpp | 30 ++++++++ .../query-ASTERIXDB-2446-2.09.query.sqlpp | 31 +++++++++ .../resources/runtimets/testsuite_sqlpp.xml | 12 ++++ 11 files changed, 315 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/3a684694/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/SqlppExpressionToPlanTranslator.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/SqlppExpressionToPlanTranslator.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/SqlppExpressionToPlanTranslator.java index 1c762af..03c4bc5 100644 --- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/SqlppExpressionToPlanTranslator.java +++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/SqlppExpressionToPlanTranslator.java @@ -23,8 +23,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Deque; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.apache.asterix.algebra.base.ILangExpressionToPlanTranslator; import org.apache.asterix.common.exceptions.CompilationException; @@ -736,16 +738,18 @@ public class SqlppExpressionToPlanTranslator extends LangExpressionToPlanTransla throws CompilationException { List<Expression> recordExprs = new ArrayList<>(); List<FieldBinding> fieldBindings = new ArrayList<>(); + Set<String> fieldNames = new HashSet<>(); + for (Projection projection : selectRegular.getProjections()) { if (projection.varStar()) { - SourceLocation sourceLoc = projection.getSourceLocation(); if (!fieldBindings.isEmpty()) { RecordConstructor recordConstr = new RecordConstructor(new ArrayList<>(fieldBindings)); - recordConstr.setSourceLocation(sourceLoc); + recordConstr.setSourceLocation(selectRegular.getSourceLocation()); recordExprs.add(recordConstr); fieldBindings.clear(); } Expression projectionExpr = projection.getExpression(); + SourceLocation sourceLoc = projection.getSourceLocation(); CallExpr toObjectExpr = new CallExpr(new FunctionSignature(BuiltinFunctions.TO_OBJECT), Collections.singletonList(projectionExpr)); toObjectExpr.setSourceLocation(sourceLoc); @@ -755,21 +759,22 @@ public class SqlppExpressionToPlanTranslator extends LangExpressionToPlanTransla recordExprs.add(ifMissingOrNullExpr); } else if (projection.star()) { if (selectBlock.hasGroupbyClause()) { - getGroupBindings(selectBlock.getGroupbyClause(), fieldBindings); + getGroupBindings(selectBlock.getGroupbyClause(), fieldBindings, fieldNames); if (selectBlock.hasLetClausesAfterGroupby()) { - getLetBindings(selectBlock.getLetListAfterGroupby(), fieldBindings); + getLetBindings(selectBlock.getLetListAfterGroupby(), fieldBindings, fieldNames); } } else if (selectBlock.hasFromClause()) { - getFromBindings(selectBlock.getFromClause(), fieldBindings); + getFromBindings(selectBlock.getFromClause(), fieldBindings, fieldNames); if (selectBlock.hasLetClauses()) { - getLetBindings(selectBlock.getLetList(), fieldBindings); + getLetBindings(selectBlock.getLetList(), fieldBindings, fieldNames); } } else if (selectBlock.hasLetClauses()) { - getLetBindings(selectBlock.getLetList(), fieldBindings); + getLetBindings(selectBlock.getLetList(), fieldBindings, fieldNames); } + } else if (projection.hasName()) { + fieldBindings.add(getFieldBinding(projection, fieldNames)); } else { - fieldBindings.add(new FieldBinding(new LiteralExpr(new StringLiteral(projection.getName())), - projection.getExpression())); + throw new CompilationException(ErrorCode.COMPILATION_ILLEGAL_STATE, projection.getSourceLocation()); } } if (!fieldBindings.isEmpty()) { @@ -789,49 +794,68 @@ public class SqlppExpressionToPlanTranslator extends LangExpressionToPlanTransla } // Generates all field bindings according to the from clause. - private void getFromBindings(FromClause fromClause, List<FieldBinding> outFieldBindings) { + private void getFromBindings(FromClause fromClause, List<FieldBinding> outFieldBindings, Set<String> outFieldNames) + throws CompilationException { for (FromTerm fromTerm : fromClause.getFromTerms()) { - outFieldBindings.add(getFieldBinding(fromTerm.getLeftVariable())); + outFieldBindings.add(getFieldBinding(fromTerm.getLeftVariable(), outFieldNames)); if (fromTerm.hasPositionalVariable()) { - outFieldBindings.add(getFieldBinding(fromTerm.getPositionalVariable())); + outFieldBindings.add(getFieldBinding(fromTerm.getPositionalVariable(), outFieldNames)); } if (!fromTerm.hasCorrelateClauses()) { continue; } for (AbstractBinaryCorrelateClause correlateClause : fromTerm.getCorrelateClauses()) { - outFieldBindings.add(getFieldBinding(correlateClause.getRightVariable())); + outFieldBindings.add(getFieldBinding(correlateClause.getRightVariable(), outFieldNames)); if (correlateClause.hasPositionalVariable()) { - outFieldBindings.add(getFieldBinding(correlateClause.getPositionalVariable())); + outFieldBindings.add(getFieldBinding(correlateClause.getPositionalVariable(), outFieldNames)); } } } } // Generates all field bindings according to the from clause. - private void getGroupBindings(GroupbyClause groupbyClause, List<FieldBinding> outFieldBindings) { + private void getGroupBindings(GroupbyClause groupbyClause, List<FieldBinding> outFieldBindings, + Set<String> outFieldNames) throws CompilationException { for (GbyVariableExpressionPair pair : groupbyClause.getGbyPairList()) { - outFieldBindings.add(getFieldBinding(pair.getVar())); + outFieldBindings.add(getFieldBinding(pair.getVar(), outFieldNames)); } if (groupbyClause.hasGroupVar()) { - outFieldBindings.add(getFieldBinding(groupbyClause.getGroupVar())); + outFieldBindings.add(getFieldBinding(groupbyClause.getGroupVar(), outFieldNames)); } if (groupbyClause.hasWithMap()) { - throw new IllegalStateException(groupbyClause.getWithVarMap().values().toString()); // no WITH in SQLPP + // no WITH in SQLPP + throw new CompilationException(ErrorCode.COMPILATION_ILLEGAL_STATE, groupbyClause.getSourceLocation(), + groupbyClause.getWithVarMap().values().toString()); } } // Generates all field bindings according to the let clause. - private void getLetBindings(List<LetClause> letClauses, List<FieldBinding> outFieldBindings) { + private void getLetBindings(List<LetClause> letClauses, List<FieldBinding> outFieldBindings, + Set<String> outFieldNames) throws CompilationException { for (LetClause letClause : letClauses) { - outFieldBindings.add(getFieldBinding(letClause.getVarExpr())); + outFieldBindings.add(getFieldBinding(letClause.getVarExpr(), outFieldNames)); } } // Generates a field binding for a variable. - private FieldBinding getFieldBinding(VariableExpr var) { - LiteralExpr fieldName = new LiteralExpr( - new StringLiteral(SqlppVariableUtil.variableNameToDisplayedFieldName(var.getVar().getValue()))); - return new FieldBinding(fieldName, var); + private FieldBinding getFieldBinding(VariableExpr varExpr, Set<String> outFieldNames) throws CompilationException { + String fieldName = SqlppVariableUtil.variableNameToDisplayedFieldName(varExpr.getVar().getValue()); + return generateFieldBinding(fieldName, varExpr, outFieldNames, varExpr.getSourceLocation()); + } + + // Generates a field binding for a named projection. + private FieldBinding getFieldBinding(Projection projection, Set<String> outFieldNames) throws CompilationException { + String fieldName = projection.getName(); + Expression fieldValueExpr = projection.getExpression(); + return generateFieldBinding(fieldName, fieldValueExpr, outFieldNames, projection.getSourceLocation()); + } + + private FieldBinding generateFieldBinding(String fieldName, Expression fieldValueExpr, Set<String> outFieldNames, + SourceLocation sourceLoc) throws CompilationException { + if (!outFieldNames.add(fieldName)) { + throw new CompilationException(ErrorCode.DUPLICATE_FIELD_NAME, sourceLoc, fieldName); + } + return new FieldBinding(new LiteralExpr(new StringLiteral(fieldName)), fieldValueExpr); } @Override http://git-wip-us.apache.org/repos/asf/asterixdb/blob/3a684694/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.01.ddl.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.01.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.01.ddl.sqlpp new file mode 100644 index 0000000..12a6034 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.01.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.empInfoType as +{ + id : bigint +}; + +create dataset empDataset(empInfoType) primary key id; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/3a684694/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.02.update.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.02.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.02.update.sqlpp new file mode 100644 index 0000000..04ab807 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.02.update.sqlpp @@ -0,0 +1,22 @@ +/* + * 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; + +load dataset empDataset using localfs ((`path`=`asterix_nc1://data/types/empDataset.adm`),(`format`=`adm`)); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/3a684694/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.03.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.03.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.03.query.sqlpp new file mode 100644 index 0000000..9577855 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.03.query.sqlpp @@ -0,0 +1,28 @@ +/* + * 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. + */ + +/* + * Description: Ensure error if there's a duplicate field name in the SELECT clause + * Project expression and constant + */ + +use test; + +select empno as a, 2 as a +from empDataset http://git-wip-us.apache.org/repos/asf/asterixdb/blob/3a684694/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.04.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.04.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.04.query.sqlpp new file mode 100644 index 0000000..5eac30e --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.04.query.sqlpp @@ -0,0 +1,28 @@ +/* + * 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. + */ + +/* + * Description: Ensure error if there's a duplicate field name in the SELECT clause + * Project expression and expression + */ + +use test; + +select empno as b, name as b +from empDataset http://git-wip-us.apache.org/repos/asf/asterixdb/blob/3a684694/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.05.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.05.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.05.query.sqlpp new file mode 100644 index 0000000..ea4372a --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.05.query.sqlpp @@ -0,0 +1,29 @@ +/* + * 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. + */ + +/* + * Description: Ensure error if there's a duplicate field name in the SELECT clause + * FROM variable and another field + */ + +use test; + +select c, empno as c +from empDataset c + http://git-wip-us.apache.org/repos/asf/asterixdb/blob/3a684694/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.06.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.06.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.06.query.sqlpp new file mode 100644 index 0000000..788577b --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.06.query.sqlpp @@ -0,0 +1,28 @@ +/* + * 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. + */ + +/* + * Description: Ensure error if there's a duplicate field name in the SELECT clause + * Project * (FROM variable) and another field + */ + +use test; + +select *, empno as d +from empDataset d http://git-wip-us.apache.org/repos/asf/asterixdb/blob/3a684694/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.07.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.07.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.07.query.sqlpp new file mode 100644 index 0000000..232d29c --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.07.query.sqlpp @@ -0,0 +1,29 @@ +/* + * 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. + */ + +/* + * Description: Ensure error if there's a duplicate field name in the SELECT clause + * Project * (LET variable) and another field + */ + +use test; + +select *, emp.name as e +from empDataset emp +let e = d.deptno http://git-wip-us.apache.org/repos/asf/asterixdb/blob/3a684694/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.08.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.08.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.08.query.sqlpp new file mode 100644 index 0000000..48c96a0 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.08.query.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. + */ + +/* + * Description: Ensure error if there's a duplicate field name in the SELECT clause + * Project * (GROUP BY key variable) and another field + */ + +use test; + +select *, count(*) as f +from empDataset emp +group by emp.age f + http://git-wip-us.apache.org/repos/asf/asterixdb/blob/3a684694/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.09.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.09.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.09.query.sqlpp new file mode 100644 index 0000000..9655bb7 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/flwor/query-ASTERIXDB-2446-2/query-ASTERIXDB-2446-2.09.query.sqlpp @@ -0,0 +1,31 @@ +/* + * 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. + */ + +/* + * Description: Ensure error if there's a duplicate field name in the SELECT clause + * Project * (LET after GROUP BY variable) and another field + */ + +use test; + +select *, count(*) as g +from empDataset emp +group by emp.age f +let g = f + 1 + http://git-wip-us.apache.org/repos/asf/asterixdb/blob/3a684694/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 04b484e..0127896 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml @@ -100,6 +100,18 @@ <expected-error>ASX0013: Duplicate field name "e"</expected-error> </compilation-unit> </test-case> + <test-case FilePath="flwor"> + <compilation-unit name="query-ASTERIXDB-2446-2"> + <output-dir compare="Text">query-ASTERIXDB-883</output-dir> + <expected-error>ASX0013: Duplicate field name "a" (in line 27, at column 20)</expected-error> + <expected-error>ASX0013: Duplicate field name "b" (in line 27, at column 20)</expected-error> + <expected-error>ASX0013: Duplicate field name "c" (in line 27, at column 11)</expected-error> + <expected-error>ASX0013: Duplicate field name "d" (in line 27, at column 11)</expected-error> + <expected-error>ASX0013: Duplicate field name "e" (in line 27, at column 14)</expected-error> + <expected-error>ASX0013: Duplicate field name "f" (in line 27, at column 11)</expected-error> + <expected-error>ASX0013: Duplicate field name "g" (in line 27, at column 11)</expected-error> + </compilation-unit> + </test-case> </test-group> <test-group name="explain"> <test-case FilePath="explain">
