ASTERIXDB-1463: add a regression test.

Change-Id: Iaf3a5a616799af2ee58ba559e1dc1db8b6e010ad
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1067
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Jianfeng Jia <jianfeng.jia@gmail.com>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/flwor/query-ASTERIXDB-1463/query-ASTERIXDB-1463.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/flwor/query-ASTERIXDB-1463/query-ASTERIXDB-1463.1.ddl.aql
new file mode 100644
index 0000000..5153d4a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/flwor/query-ASTERIXDB-1463/query-ASTERIXDB-1463.1.ddl.aql
@@ -0,0 +1,81 @@
+/*
+ * 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 dataverse test;
+
+create type typeUser if not exists as open {
+    id: int64,
+    name: string,
+    screen_name : string,
+    lang : string,
+    location: string,
+    create_at: date,
+    description: string,
+    followers_count: int32,
+    friends_count: int32,
+    statues_count: int64
+}
+
+create type typePlace if not exists as open{
+    country : string,
+    country_code : string,
+    full_name : string,
+    id : string,
+    name : string,
+    place_type : string,
+    bounding_box : rectangle
+}
+
+create type typeGeoTag if not exists as open {
+    stateID: int32,
+    stateName: string,
+    countyID: int32,
+    countyName: string,
+    cityID: int32?,
+    cityName: string?
+}
+
+create type typeTweet if not exists as open{
+    create_at : datetime,
+    id: int64,
+    "text": string,
+    in_reply_to_status : int64,
+    in_reply_to_user : int64,
+    favorite_count : int64,
+    coordinate: point?,
+    retweet_count : int64,
+    lang : string,
+    is_retweet: boolean,
+    hashtags : {{ string }} ?,
+    user_mentions : {{ int64 }} ? ,
+    user : typeUser,
+    place : typePlace?,
+    geo_tag: typeGeoTag
+}
+
+create dataset ds_tweet(typeTweet) if not exists primary key id;
+
+create index text_idx if not exists on ds_tweet("text") type keyword;
+create index location_idx if not exists on ds_tweet(coordinate) type rtree;
+create index time_idx if not exists on ds_tweet(create_at) type btree;
+create index state_idx if not exists on ds_tweet(geo_tag.stateID) type btree;
+create index county_idx if not exists on ds_tweet(geo_tag.countyID) type btree;
+create index city_idx if not exists on ds_tweet(geo_tag.cityID) type btree;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/flwor/query-ASTERIXDB-1463/query-ASTERIXDB-1463.2.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/flwor/query-ASTERIXDB-1463/query-ASTERIXDB-1463.2.update.aql
new file mode 100644
index 0000000..9d3c8a1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/flwor/query-ASTERIXDB-1463/query-ASTERIXDB-1463.2.update.aql
@@ -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 dataverse test;
+
+load dataset ds_tweet using localfs
+(("path"="asterix_nc1://data/twitter/sample.adm"),("format"="adm"));
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/flwor/query-ASTERIXDB-1463/query-ASTERIXDB-1463.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/flwor/query-ASTERIXDB-1463/query-ASTERIXDB-1463.3.query.aql
new file mode 100644
index 0000000..3d63189
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/flwor/query-ASTERIXDB-1463/query-ASTERIXDB-1463.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.
+ */
+
+use dataverse test
+
+let $common := (
+   for $t in dataset ds_tweet
+   where similarity-jaccard(word-tokens($t."text"), word-tokens("document")) > 0.0
+      and contains($t."text", "hate")
+   where
+        $t."create_at">= datetime("2012-04-30T18:53:42.894Z")
+        and $t."create_at" <= datetime("2012-05-03T19:25:11.000Z")
+   let $set := [ 72,37,51,24,11,10,34,42,9,44,15,48,35,4,40,6,20,32,8,49,12,22,28,1,13,45,5,47,21,29,54,17,18,39,19,
+                 55,26,27,31,56,41,46,16,30,53,38,25,36,50,33,23,2 ]
+   for $sid in $set
+   where $t.geo_tag.stateID = $sid
+   return $t
+)
+
+let $hashtag := (
+  for $t in $common
+  where not(is-null($t.hashtags))
+  for $h in $t.hashtags
+  group by $tag := $h with $h
+  let $c := count($h)
+  order by $c desc, $tag
+  limit 50
+  return { "key": $tag, "count" : $c}
+)
+return $hashtag
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
index 4a2f78e..862ca26 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -349,6 +349,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="flwor">
+      <compilation-unit name="query-ASTERIXDB-1463">
+        <output-dir compare="Text">query-ASTERIXDB-1485</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="flwor">
       <compilation-unit name="query-ASTERIXDB-1485">
         <output-dir compare="Text">query-ASTERIXDB-1485</output-dir>
       </compilation-unit>