This is an automated email from the ASF dual-hosted git repository. htowaileb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 8149d01b423192c8aa9487ae1e62094fd3f93e22 Author: Ali Alsuliman <[email protected]> AuthorDate: Tue Nov 7 10:55:03 2023 -0800 [ASTERIXDB-3301][COMP] NPE for subquery with only SELECT ELEMENT - user model changes: no - storage format changes: no - interface changes: no Details: When a subquery consists of only SELECT ELEMENT, a NullPointerException is encountered. The exception is due to the fact that the base/input operator for the SUBPLAN of the subquery starts with a 'null' op that gets replaced by a NTS op later after translating the subquery. This works fine, but when the subquery is only a SELECT ELEMENT expression, there are no intermediate operators translated and therefore the root op of the subplan tries to reference the input op directly which is 'null' at the time. Change-Id: I5b314c014798daf4890f75998138954e3d858445 Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17928 Integration-Tests: Jenkins <[email protected]> Reviewed-by: Wail Alkowaileet <[email protected]> Tested-by: Jenkins <[email protected]> --- .../translator/LangExpressionToPlanTranslator.java | 2 +- .../SqlppExpressionToPlanTranslator.java | 8 +++++-- .../select_element/select_element.01.ddl.sqlpp | 28 ++++++++++++++++++++++ .../select_element/select_element.02.query.sqlpp | 24 +++++++++++++++++++ .../select_element/select_element.03.query.sqlpp | 24 +++++++++++++++++++ .../select_element/select_element.04.query.sqlpp | 24 +++++++++++++++++++ .../select_element/select_element.05.query.sqlpp | 24 +++++++++++++++++++ .../select_element/select_element.06.query.sqlpp | 24 +++++++++++++++++++ .../select_element/select_element.07.query.sqlpp | 23 ++++++++++++++++++ .../select_element/select_element.08.query.sqlpp | 23 ++++++++++++++++++ .../select_element/select_element.09.query.sqlpp | 23 ++++++++++++++++++ .../select_element/select_element.10.query.sqlpp | 23 ++++++++++++++++++ .../select_element/select_element.11.query.sqlpp | 23 ++++++++++++++++++ .../select_element/select_element.12.query.sqlpp | 24 +++++++++++++++++++ .../select_element/select_element.13.query.sqlpp | 23 ++++++++++++++++++ .../select_element/select_element.14.query.sqlpp | 24 +++++++++++++++++++ .../select_element/select_element.15.query.sqlpp | 23 ++++++++++++++++++ .../select_element/select_element.16.query.sqlpp | 24 +++++++++++++++++++ .../select_element/select_element.17.query.sqlpp | 24 +++++++++++++++++++ .../select_element/select_element.99.ddl.sqlpp | 20 ++++++++++++++++ .../subquery/select_element/select_element.02.adm | 3 +++ .../subquery/select_element/select_element.03.adm | 3 +++ .../subquery/select_element/select_element.04.adm | 3 +++ .../subquery/select_element/select_element.05.adm | 3 +++ .../subquery/select_element/select_element.06.adm | 3 +++ .../subquery/select_element/select_element.07.adm | 3 +++ .../subquery/select_element/select_element.08.adm | 3 +++ .../subquery/select_element/select_element.09.adm | 3 +++ .../subquery/select_element/select_element.10.adm | 3 +++ .../subquery/select_element/select_element.11.adm | 3 +++ .../subquery/select_element/select_element.12.adm | 3 +++ .../subquery/select_element/select_element.13.adm | 3 +++ .../subquery/select_element/select_element.14.adm | 3 +++ .../subquery/select_element/select_element.15.adm | 3 +++ .../subquery/select_element/select_element.16.adm | 3 +++ .../subquery/select_element/select_element.17.adm | 3 +++ .../test/resources/runtimets/testsuite_sqlpp.xml | 5 ++++ 37 files changed, 485 insertions(+), 3 deletions(-) diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java index daa1d2f7fb..dabe327f7a 100644 --- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java +++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java @@ -1776,7 +1776,7 @@ abstract class LangExpressionToPlanTranslator protected Pair<ILogicalOperator, LogicalVariable> aggListifyForSubquery(LogicalVariable var, Mutable<ILogicalOperator> opRef, boolean bProject) { - SourceLocation sourceLoc = opRef.getValue().getSourceLocation(); + SourceLocation sourceLoc = opRef.getValue() != null ? opRef.getValue().getSourceLocation() : null; AggregateFunctionCallExpression funAgg = BuiltinFunctions.makeAggregateFunctionExpression(BuiltinFunctions.LISTIFY, new ArrayList<>()); funAgg.getArguments().add(new MutableObject<>(new VariableReferenceExpression(var))); 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 ddabaa0934..1d9c57bbf3 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 @@ -206,7 +206,9 @@ public class SqlppExpressionToPlanTranslator extends LangExpressionToPlanTransla } Pair<ILogicalOperator, LogicalVariable> select = selectExpression.getSelectSetOperation().accept(this, currentOpRef); - currentOpRef = new MutableObject<>(select.first); + if (select.first != null) { + currentOpRef = new MutableObject<>(select.first); + } if (selectExpression.hasOrderby()) { currentOpRef = new MutableObject<>(selectExpression.getOrderbyClause().accept(this, currentOpRef).first); } @@ -768,7 +770,9 @@ public class SqlppExpressionToPlanTranslator extends LangExpressionToPlanTransla } else { ProjectOperator pr = new ProjectOperator(resVar); pr.getInputs().add(returnOpRef); - pr.setSourceLocation(returnOpRef.getValue().getSourceLocation()); + if (returnOpRef.getValue() != null) { + pr.setSourceLocation(returnOpRef.getValue().getSourceLocation()); + } return new Pair<>(pr, resVar); } } diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.01.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.01.ddl.sqlpp new file mode 100644 index 0000000000..e3c9e55416 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.01.ddl.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. + */ + +DROP DATAVERSE test IF EXISTS; +CREATE DATAVERSE test; +USE test; + +CREATE OR REPLACE FUNCTION `fun0` (data) { data + 1 }; +CREATE OR REPLACE FUNCTION `fun1` (data) { ( SELECT RAW data ) }; +CREATE OR REPLACE FUNCTION `fun2` (data) { ( SELECT RAW (SELECT RAW data) ) }; +CREATE OR REPLACE FUNCTION `fun3` (data) { ( SELECT data ) }; +CREATE OR REPLACE FUNCTION `fun4` (data) { ( SELECT (SELECT data) AS x) }; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.02.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.02.query.sqlpp new file mode 100644 index 0000000000..0a298b23f6 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.02.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; + +FROM [1,2,3] a +LET test = fun0(a) +SELECT a, test; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.03.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.03.query.sqlpp new file mode 100644 index 0000000000..d4c60c9fb8 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.03.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; + +FROM [1,2,3] a +LET test = fun1(a) +SELECT a, test; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.04.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.04.query.sqlpp new file mode 100644 index 0000000000..7dc96f05b1 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.04.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; + +FROM [1,2,3] a +LET test = fun2(a) +SELECT a, test; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.05.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.05.query.sqlpp new file mode 100644 index 0000000000..4e579706e8 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.05.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; + +FROM [1,2,3] a +LET test = fun3(a) +SELECT a, test; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.06.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.06.query.sqlpp new file mode 100644 index 0000000000..fc0402b2af --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.06.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; + +FROM [1,2,3] a +LET test = fun4(a) +SELECT a, test; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.07.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.07.query.sqlpp new file mode 100644 index 0000000000..60faeb8842 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.07.query.sqlpp @@ -0,0 +1,23 @@ +/* + * 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; + +FROM [1,2,3] a +SELECT a, fun0(a); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.08.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.08.query.sqlpp new file mode 100644 index 0000000000..6d470c7248 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.08.query.sqlpp @@ -0,0 +1,23 @@ +/* + * 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; + +FROM [1,2,3] a +SELECT a, fun1(a); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.09.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.09.query.sqlpp new file mode 100644 index 0000000000..7c9637016f --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.09.query.sqlpp @@ -0,0 +1,23 @@ +/* + * 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; + +FROM [1,2,3] a +SELECT a, fun2(a); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.10.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.10.query.sqlpp new file mode 100644 index 0000000000..975b7088e8 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.10.query.sqlpp @@ -0,0 +1,23 @@ +/* + * 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; + +FROM [1,2,3] a +SELECT a, fun3(a); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.11.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.11.query.sqlpp new file mode 100644 index 0000000000..fc50baa7ff --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.11.query.sqlpp @@ -0,0 +1,23 @@ +/* + * 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; + +FROM [1,2,3] a +SELECT a, fun4(a); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.12.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.12.query.sqlpp new file mode 100644 index 0000000000..0c3dc54fdc --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.12.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; + +FROM [1,2,3] a +LET test = (SELECT RAW a) +SELECT a, test; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.13.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.13.query.sqlpp new file mode 100644 index 0000000000..54e82fde50 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.13.query.sqlpp @@ -0,0 +1,23 @@ +/* + * 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; + +FROM [1,2,3] a +SELECT a, (SELECT RAW a); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.14.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.14.query.sqlpp new file mode 100644 index 0000000000..4bc8a67f73 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.14.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; + +FROM [1,2,3] a +LET test = ( SELECT RAW (SELECT RAW a) ) +SELECT a, test; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.15.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.15.query.sqlpp new file mode 100644 index 0000000000..cfa7a65e8e --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.15.query.sqlpp @@ -0,0 +1,23 @@ +/* + * 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; + +FROM [1,2,3] a +SELECT a, ( SELECT RAW (SELECT RAW a) ); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.16.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.16.query.sqlpp new file mode 100644 index 0000000000..978b6cb198 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.16.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; + +FROM [1,2,3] a +LET test = ( (LET x = 6 SELECT RAW a+x) ) +SELECT a, test; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.17.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.17.query.sqlpp new file mode 100644 index 0000000000..392da0995c --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.17.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; + +FROM [1,2,3] a +LET test = ( (LET x = random() SELECT RAW a+x) ) +SELECT a, floor(test[0]); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.99.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.99.ddl.sqlpp new file mode 100644 index 0000000000..36b2bab543 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/subquery/select_element/select_element.99.ddl.sqlpp @@ -0,0 +1,20 @@ +/* + * 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; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.02.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.02.adm new file mode 100644 index 0000000000..f6fb5bde61 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.02.adm @@ -0,0 +1,3 @@ +{ "a": 1, "test": 2 } +{ "a": 2, "test": 3 } +{ "a": 3, "test": 4 } \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.03.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.03.adm new file mode 100644 index 0000000000..ea413fe5f7 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.03.adm @@ -0,0 +1,3 @@ +{ "a": 1, "test": [ 1 ] } +{ "a": 2, "test": [ 2 ] } +{ "a": 3, "test": [ 3 ] } \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.04.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.04.adm new file mode 100644 index 0000000000..2cf7df3a71 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.04.adm @@ -0,0 +1,3 @@ +{ "a": 1, "test": [ [ 1 ] ] } +{ "a": 2, "test": [ [ 2 ] ] } +{ "a": 3, "test": [ [ 3 ] ] } \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.05.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.05.adm new file mode 100644 index 0000000000..59b19361b0 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.05.adm @@ -0,0 +1,3 @@ +{ "a": 1, "test": [ { "data": 1 } ] } +{ "a": 2, "test": [ { "data": 2 } ] } +{ "a": 3, "test": [ { "data": 3 } ] } \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.06.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.06.adm new file mode 100644 index 0000000000..3eed37c682 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.06.adm @@ -0,0 +1,3 @@ +{ "a": 1, "test": [ { "x": [ { "data": 1 } ] } ] } +{ "a": 2, "test": [ { "x": [ { "data": 2 } ] } ] } +{ "a": 3, "test": [ { "x": [ { "data": 3 } ] } ] } \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.07.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.07.adm new file mode 100644 index 0000000000..944e5a2de7 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.07.adm @@ -0,0 +1,3 @@ +{ "a": 1, "$1": 2 } +{ "a": 2, "$1": 3 } +{ "a": 3, "$1": 4 } \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.08.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.08.adm new file mode 100644 index 0000000000..c8f629ba0e --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.08.adm @@ -0,0 +1,3 @@ +{ "a": 1, "$1": [ 1 ] } +{ "a": 2, "$1": [ 2 ] } +{ "a": 3, "$1": [ 3 ] } \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.09.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.09.adm new file mode 100644 index 0000000000..325d24fef4 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.09.adm @@ -0,0 +1,3 @@ +{ "a": 1, "$1": [ [ 1 ] ] } +{ "a": 2, "$1": [ [ 2 ] ] } +{ "a": 3, "$1": [ [ 3 ] ] } \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.10.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.10.adm new file mode 100644 index 0000000000..a5ef5cd748 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.10.adm @@ -0,0 +1,3 @@ +{ "a": 1, "$1": [ { "data": 1 } ] } +{ "a": 2, "$1": [ { "data": 2 } ] } +{ "a": 3, "$1": [ { "data": 3 } ] } \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.11.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.11.adm new file mode 100644 index 0000000000..1936e656e9 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.11.adm @@ -0,0 +1,3 @@ +{ "a": 1, "$1": [ { "x": [ { "data": 1 } ] } ] } +{ "a": 2, "$1": [ { "x": [ { "data": 2 } ] } ] } +{ "a": 3, "$1": [ { "x": [ { "data": 3 } ] } ] } \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.12.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.12.adm new file mode 100644 index 0000000000..ea413fe5f7 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.12.adm @@ -0,0 +1,3 @@ +{ "a": 1, "test": [ 1 ] } +{ "a": 2, "test": [ 2 ] } +{ "a": 3, "test": [ 3 ] } \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.13.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.13.adm new file mode 100644 index 0000000000..c8f629ba0e --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.13.adm @@ -0,0 +1,3 @@ +{ "a": 1, "$1": [ 1 ] } +{ "a": 2, "$1": [ 2 ] } +{ "a": 3, "$1": [ 3 ] } \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.14.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.14.adm new file mode 100644 index 0000000000..2cf7df3a71 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.14.adm @@ -0,0 +1,3 @@ +{ "a": 1, "test": [ [ 1 ] ] } +{ "a": 2, "test": [ [ 2 ] ] } +{ "a": 3, "test": [ [ 3 ] ] } \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.15.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.15.adm new file mode 100644 index 0000000000..325d24fef4 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.15.adm @@ -0,0 +1,3 @@ +{ "a": 1, "$1": [ [ 1 ] ] } +{ "a": 2, "$1": [ [ 2 ] ] } +{ "a": 3, "$1": [ [ 3 ] ] } \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.16.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.16.adm new file mode 100644 index 0000000000..0f584e9821 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.16.adm @@ -0,0 +1,3 @@ +{ "a": 1, "test": [ 7 ] } +{ "a": 2, "test": [ 8 ] } +{ "a": 3, "test": [ 9 ] } \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.17.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.17.adm new file mode 100644 index 0000000000..74fd97fb7c --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/subquery/select_element/select_element.17.adm @@ -0,0 +1,3 @@ +{ "a": 1, "$1": 1.0 } +{ "a": 2, "$1": 2.0 } +{ "a": 3, "$1": 3.0 } \ 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 ee5fafb594..0ab9672789 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml @@ -11326,6 +11326,11 @@ </test-case> </test-group> <test-group name="subquery"> + <test-case FilePath="subquery"> + <compilation-unit name="select_element"> + <output-dir compare="Text">select_element</output-dir> + </compilation-unit> + </test-case> <test-case FilePath="subquery"> <compilation-unit name="aggregate_join"> <output-dir compare="Text">aggregate_join</output-dir>
