ASTERIXDB-1204: fixed LIMIT pushdown into join
- Added a test case
Change-Id: Id4bb09bddca64b26598d693d295fdc3ec9d63052
Reviewed-on: https://asterix-gerrit.ics.uci.edu/633
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterix-app/src/test/resources/runtimets/queries/orderby_limit/limit_on_variable_01/limit_on_variable_01.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/limit_on_variable_01/limit_on_variable_01.1.ddl.aql
new file mode 100644
index 0000000..11daffe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/limit_on_variable_01/limit_on_variable_01.1.ddl.aql
@@ -0,0 +1,37 @@
+/*
+ * 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 : Limit on a variable should work.
+ * Issue : ASTERIXDB-1204
+ * Expected Result : Success
+ *
+*/
+
+drop dataverse ifVerse if exists;
+create dataverse ifVerse;
+use dataverse ifVerse;
+
+create type ifType as open
+{
+ id: int32
+}
+
+create dataset ifds(ifType)
+primary key id;
diff --git a/asterix-app/src/test/resources/runtimets/queries/orderby_limit/limit_on_variable_01/limit_on_variable_01.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/limit_on_variable_01/limit_on_variable_01.2.update.aql
new file mode 100644
index 0000000..88d1d2a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/limit_on_variable_01/limit_on_variable_01.2.update.aql
@@ -0,0 +1,59 @@
+/*
+ * 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 : Limit on a variable should work.
+ * Issue : ASTERIXDB-1204
+ * Expected Result : Success
+ *
+*/
+
+use dataverse ifVerse;
+
+insert into dataset ifds(
+{
+ "id":0,
+ "names":{
+ "count": "1",
+ "name" :{
+ "firstName" : "wail",
+ "lastName" : "Alkowaileet"
+ }
+ }
+}
+);
+
+insert into dataset ifds(
+{
+ "id":1,
+ "names":{
+ "count": "2",
+ "name" :[
+ {
+ "firstName" : "wail",
+ "lastName" : "Alkowaileet"
+ },
+ {
+ "firstName" : "Sattam",
+ "lastName" : "Alsubaiee"
+ }
+ ]
+ }
+}
+);
diff --git a/asterix-app/src/test/resources/runtimets/queries/orderby_limit/limit_on_variable_01/limit_on_variable_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/limit_on_variable_01/limit_on_variable_01.3.query.aql
new file mode 100644
index 0000000..c2015b6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/orderby_limit/limit_on_variable_01/limit_on_variable_01.3.query.aql
@@ -0,0 +1,46 @@
+/*
+ * 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 : Limit on a variable should work.
+ * Issue : ASTERIXDB-1204
+ * Expected Result : Success
+ *
+*/
+
+use dataverse ifVerse;
+
+let $coAuthList := (for $x in dataset ifds
+let $nameString := "names"
+where $x.names.count != "1"
+return
+{$nameString:$x.names.name}
+)
+
+let $coAuth := (for $x in $coAuthList
+for $y in $x.names
+return {
+"firstName" : $y.firstName,
+"lastName" : $y.lastName
+}
+)
+
+for $x in $coAuth
+limit 1
+return $x;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/orderby_limit/limit_on_variable_01/limit_on_variable_01.1.adm b/asterix-app/src/test/resources/runtimets/results/orderby_limit/limit_on_variable_01/limit_on_variable_01.1.adm
new file mode 100644
index 0000000..aa0442d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/orderby_limit/limit_on_variable_01/limit_on_variable_01.1.adm
@@ -0,0 +1 @@
+{ "firstName": "wail", "lastName": "Alkowaileet" }
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index 99b195d..48dcbb4 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -4296,6 +4296,11 @@
</test-group>
<test-group name="orderby_limit">
<test-case FilePath="orderby_limit">
+ <compilation-unit name="limit_on_variable_01">
+ <output-dir compare="Text">limit_on_variable_01</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="orderby_limit">
<compilation-unit name="orderby_limit_01">
<output-dir compare="Text">orderby_limit_01</output-dir>
</compilation-unit>