SQL++ parser:
1. refactored asterix-aql to become asterix-lang-common and asterix-lang-aql, where the former is the common part for different languages;
2. added asterix-lang-sqlpp on top of asterix-lang-common;
3. ported parser tests, optimizer tests and runtime tests in asterix-app to their sql++ version, and added parser tests for all the queries.

Change-Id: Ie5af4e3b692ca017ec047a1ba3b404a51beb3a2e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/466
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/1.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/1.sqlpp
new file mode 100644
index 0000000..4933e4c
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/1.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.
+ */
+
+select element {'name':user.name}
+from  User as user
+where some i in user.interests satisfies (i = 'movies')
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/2.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/2.sqlpp
new file mode 100644
index 0000000..4921b58
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/2.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+select element {'sig_name':sig_name,'total_count':sig_sponsorship_count,'chapter_breakdown':by_chapter}
+from  Event as event,
+      event.sponsoring_sigs as sponsor
+with  es as {'event':event,'sponsor':sponsor}
+group by sponsor.sig_name as sig_name
+with  sig_sponsorship_count as count(es),
+      by_chapter as (
+      select element {'chapter_name':chapter_name,'escount':count(es)}
+      from  es as e
+      group by e.sponsor.chapter_name as chapter_name
+  )
+order by sig_sponsorship_count desc
+limit 5
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/4.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/4.sqlpp
new file mode 100644
index 0000000..90993e89
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/4.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.
+ */
+
+select element {'similar_sigs':similar_sigs}
+from  SIGroup as sig
+with  similar_sigs as (
+      select element {'sig_name':similar_sig.name}
+      from  SIGroup as similar_sig
+      where ((similar_sig != sig) and (similar_sig.interests ~= sig.interests))
+  )
+where (sig.name = 'Movie-Watchers')
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/5.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/5.sqlpp
new file mode 100644
index 0000000..d8cb6ae
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/5.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.
+ */
+
+select element {'collocated_evnets':collocated_events}
+from  Event as event
+with  collocated_events as (
+      select element {'event_name':collocated_event.name}
+      from  Events as collocated_event
+      where ((collocated_event.location.street ~= event.location.street) and (collocated_event.location.city = event.location.city) and (collocated_event.location.state = event.location.state) and (collocated_event.location.zip = event.location.zip))
+  )
+where (event.name = 'The Night of the Ad Eaters, 29th edition')
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/6.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/6.sqlpp
new file mode 100644
index 0000000..5eae7fd
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/6.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.
+ */
+
+select element {'user_name':user.name,'similar_users':similar_users}
+from  Users as user
+with  similar_users as (
+      select element {'user_name':similar_user.name,'similarity':similarity}
+      from  Users as similar_user
+      with  similarity as jaccard_similarity(user.interests,similar_user.interests)
+      where ((user != similar_user) and (similarity >= 0.75))
+      order by similarity desc
+      limit 10
+  )
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/ANYInFieldAccessor.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/ANYInFieldAccessor.sqlpp
new file mode 100644
index 0000000..bca9e57
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/ANYInFieldAccessor.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.
+ */
+
+select element {'name':user.name,'movie':mv.movie}
+from  User as user,
+      Movie as mv
+where some i in user.interests satisfies (i.movie = mv.movie[?])
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/IfInFLOWGR.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/IfInFLOWGR.sqlpp
new file mode 100644
index 0000000..294730f
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/IfInFLOWGR.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+select element if ((i > j))
+    then i
+    else j
+from  [1,2,30,40] as i,
+      {{4,5,6}} as j
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/IfThenElse.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/IfThenElse.sqlpp
new file mode 100644
index 0000000..f346d1a
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/IfThenElse.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.
+ */
+
+select element if ((2 > 1))
+    then 20
+    else 10;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/LetFor.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/LetFor.sqlpp
new file mode 100644
index 0000000..5c118fa
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/LetFor.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.
+ */
+
+with  users as User
+select element {'name':user.name}
+from  users as user
+where some i in user.interests satisfies (i = 'movies')
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/ListConstructor.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/ListConstructor.sqlpp
new file mode 100644
index 0000000..a9d7a1e
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/ListConstructor.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.
+ */
+
+select element (i + j)
+from  [1,2,3] as i,
+      {{4,5,6}} as j
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/addOperator.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/addOperator.sqlpp
new file mode 100644
index 0000000..23cc57d
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/addOperator.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.
+ */
+
+1 + 1 - 2;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/columnalias.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/columnalias.sqlpp
new file mode 100644
index 0000000..746660c
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/columnalias.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.
+ */
+
+SELECT SQRT(t.a*t.b) AS root FROM tbl_name t
+GROUP BY root
+WITH u AS root
+HAVING root > 0
+ORDER BY u; 
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/columnalias2.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/columnalias2.sqlpp
new file mode 100644
index 0000000..8eeea85
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/columnalias2.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.
+ */
+
+SELECT SQRT(t.a*t.b) AS root FROM tbl_name root
+GROUP BY root.id
+WITH u AS root.time
+HAVING root.orders > 0
+ORDER BY u; 
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/columnalias3.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/columnalias3.sqlpp
new file mode 100644
index 0000000..8226362
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/columnalias3.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.
+ */
+
+SELECT ELEMENT {'root': SQRT(t.a*t.b)} FROM tbl_name t
+GROUP BY root
+WITH u AS root
+HAVING root > 0
+ORDER BY u; 
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/constant.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/constant.sqlpp
new file mode 100644
index 0000000..9d2e0ed
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/constant.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.
+ */
+
+-1 + 1;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/createInternalDataSet.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/createInternalDataSet.sqlpp
new file mode 100644
index 0000000..43b7626
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/createInternalDataSet.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.
+ */
+
+create  table ds1(someType) primary key id;
+
+create  table ds2(someType) primary key id;
+
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/del-dataset.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/del-dataset.sqlpp
new file mode 100644
index 0000000..e9600e4
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/del-dataset.sqlpp
@@ -0,0 +1,52 @@
+/*
+ * 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  database demo0927 if exists;
+create  database demo0927;
+
+use demo0927;
+
+
+create type demo0927.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  lastorder : {
+      oid : int32,
+      total : float
+  }
+
+}
+
+create type demo0927.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Customers(CustomerType) primary key cid on group1;
+
+drop  table Customers;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/fieldAccessor.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/fieldAccessor.sqlpp
new file mode 100644
index 0000000..4ad60bc
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/fieldAccessor.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.
+ */
+
+with  bla as {'name':'value'}
+select element (bla."name" = bla.name)
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/from_collection_array.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_collection_array.sqlpp
new file mode 100644
index 0000000..1235b6c
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_collection_array.sqlpp
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+from [ 10, 20, 30 ] as x
+select element x;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/from_collection_bag.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_collection_bag.sqlpp
new file mode 100644
index 0000000..c5219ff
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_collection_bag.sqlpp
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+from {{ 10, 20, 30 }} as x
+select element x;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/from_inner_correlate.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_inner_correlate.sqlpp
new file mode 100644
index 0000000..30d0ecf
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_inner_correlate.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 sensors AS s inner correlate s.readings AS r
+select element r;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/from_inner_flatten.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_inner_flatten.sqlpp
new file mode 100644
index 0000000..ffd21bb
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_inner_flatten.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;
+
+select s.sensor as sensor, r as reading
+from sensors as s, s.readings as r;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/from_inner_join.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_inner_join.sqlpp
new file mode 100644
index 0000000..f2ca69c
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_inner_join.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * 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 m.sensor as sensor, s.readings as readings, m.location as location
+from sensors as s
+join sensorMeta as m
+on s.sensor = m.sensor;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/from_left_correlate.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_left_correlate.sqlpp
new file mode 100644
index 0000000..47385a7
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_left_correlate.sqlpp
@@ -0,0 +1,57 @@
+/*
+ * 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_022;
+
+select sl.location as location, sr.gas as gas, sr.readings as readings
+from {{
+     {
+        'sensor' : 1,
+        'location': point('0.0,0.0')
+    },
+    {
+        'sensor' : 2,
+        'location': point('0.0,1.0')
+    },
+    {
+        'sensor' : 3,
+        'location': point('0.0,1.0')
+    }
+}} as sl
+left correlate {{
+     {
+        'id' : 1,
+        'sensor' : 1,
+        'gas' : 'co2',
+        'readings': {{ 0.2, 0.3 }}
+    },
+    {
+        'id' : 2,
+        'sensor' : 2,
+        'gas' : 'co2',
+        'readings': {{ 0.4, 0.2 }}
+    },
+    {
+        'id' : 3,
+        'sensor' : 2,
+        'gas' : 'no2',
+         'readings': {{ 0.1 }}
+    }
+}} as sr
+where sl.sensor = sr.sensor;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/from_left_correlate2.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_left_correlate2.sqlpp
new file mode 100644
index 0000000..eeb02cd
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_left_correlate2.sqlpp
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+from {{
+        {
+            'sensor' : 1,
+            'readings': {{ 0.2, 0.3 }}
+        },
+        {
+            'sensor': 2,
+            'readings': {{ 0.4, 0.2 }}
+        },
+        {
+            'sensor': 3,
+            'readings': {{}}
+        }
+}} as s left outer correlate s.readings as r
+select element r;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/from_left_outer_join.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_left_outer_join.sqlpp
new file mode 100644
index 0000000..2169a3e
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_left_outer_join.sqlpp
@@ -0,0 +1,57 @@
+/*
+ * 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_021;
+
+select sl.location as location, sr.gas as gas, sr.readings as readings
+from {{
+     {
+        'sensor' : 1,
+        'location': point('0.0,0.0')
+    },
+    {
+        'sensor' : 2,
+        'location': point('0.0,1.0')
+    },
+    {
+        'sensor' : 3,
+        'location': point('0.0,1.0')
+    }
+}} as sl
+left outer join {{
+     {
+        'id' : 1,
+        'sensor' : 1,
+        'gas' : 'co2',
+        'readings': {{ 0.2, 0.3 }}
+    },
+    {
+        'id' : 2,
+        'sensor' : 2,
+        'gas' : 'co2',
+        'readings': {{ 0.4, 0.2 }}
+    },
+    {
+        'id' : 3,
+        'sensor' : 2,
+        'gas' : 'no2',
+         'readings': {{ 0.1 }}
+    }
+}} as sr
+on sl.sensor = sr.sensor;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/from_where_select_clause.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_where_select_clause.sqlpp
new file mode 100644
index 0000000..b162713
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/from_where_select_clause.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.
+ */
+
+from [ 10, 20, 30, 10, 10 ] as x
+where x = 10
+select  element x;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/functionDecl.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/functionDecl.sqlpp
new file mode 100644
index 0000000..e0d13a4
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/functionDecl.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+declare function add(a,b) {
+(a + b)
+};
+declare function minus(a,b) {
+(a - b)
+};
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/functionDecl1.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/functionDecl1.sqlpp
new file mode 100644
index 0000000..2d1d8af
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/functionDecl1.sqlpp
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+declare function calculate(events) {
+(
+    select element {'sig_name':sig_name,'total_count':sig_sponsorship_count,'chapter_breakdown':by_chapter}
+    from  events as event,
+          event.sponsoring_sigs as sponsor
+    with  es as {'event':event,'sponsor':sponsor}
+    group by sponsor.sig_name as sig_name
+    with  sig_sponsorship_count as count(es),
+          by_chapter as (
+          select element {'chapter_name':chapter_name,'escount':count(es)}
+          from  es as e
+          group by e.sponsor.chapter_name as chapter_name
+      )
+    order by sig_sponsorship_count desc
+    limit 5
+)
+};
+with  result as calculate(Events)
+select element result
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/functionDecl2.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/functionDecl2.sqlpp
new file mode 100644
index 0000000..ddda48e
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/functionDecl2.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.
+ */
+
+declare function GT(a,b) {
+if ((a > b))
+    then true
+    else false
+};
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/functionDecl3.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/functionDecl3.sqlpp
new file mode 100644
index 0000000..da8ab9a
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/functionDecl3.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.
+ */
+
+declare function "function with spaces"(a,b) {
+'string with spaces'
+};
+"function with spaces"(1,2);
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/groupby_clause_count.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/groupby_clause_count.sqlpp
new file mode 100644
index 0000000..caa1a1e
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/groupby_clause_count.sqlpp
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+from {{
+        {
+            'gas' : 'co',
+            'num' : 0.1
+        },
+        {
+            'gas' : 'co',
+            'num' : 0.2
+        },
+         {
+            'gas' : 'co',
+            'num' : 0.3
+        },
+        {
+            'gas' : 'co2',
+            'num' : 0.4
+        },
+         {
+            'gas' : 'no2',
+            'num' : 0.5
+        },
+        {
+            'gas' : 'no2',
+            'num' : 0.6
+        }
+}} AS r
+group by r.gas as g
+select element count(r);
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/load-del-dataset.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/load-del-dataset.sqlpp
new file mode 100644
index 0000000..d08a13b
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/load-del-dataset.sqlpp
@@ -0,0 +1,53 @@
+/*
+ * 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  database demo0927 if exists;
+create  database demo0927;
+
+use demo0927;
+
+
+create type demo0927.CustomerType as
+ closed {
+  cid : int32,
+  name : string,
+  age : int32?,
+  address : AddressType?,
+  lastorder : {
+      oid : int32,
+      total : float
+  }
+
+}
+
+create type demo0927.AddressType as
+ closed {
+  number : int32,
+  street : string,
+  city : string
+}
+
+create  nodegroup group1 if not exists  on 
+    nc1,
+    nc2
+;
+create  table Customers(CustomerType) primary key cid on group1;
+
+load  table Customers using "org.apache.asterix.external.dataset.adapter.NCFileSystemAdapter" (("path"="nc1:///tmp/customerData.json"),("format"="adm")) pre-sorted;
+
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/mulOperator.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/mulOperator.sqlpp
new file mode 100644
index 0000000..c2e6b6f
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/mulOperator.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.
+ */
+
+1 + 2 * 3 - 4;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/nestedFLWOGR.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/nestedFLWOGR.sqlpp
new file mode 100644
index 0000000..c5719ec
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/nestedFLWOGR.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+select element {'name':user.name}
+from  (
+    with  data as User
+    select element data
+) as user
+where some i in user.interests satisfies (i = 'movies')
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/nestedFLWOGR1.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/nestedFLWOGR1.sqlpp
new file mode 100644
index 0000000..704f348
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/nestedFLWOGR1.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.
+ */
+
+select element (
+    select element k
+    from  if ((i > j))
+        then i
+        else j as k
+    where (k < 10)
+)
+from  [1,2,30,40] as i,
+      {{4,5,6}} as j
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/nestedFLWOGR2.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/nestedFLWOGR2.sqlpp
new file mode 100644
index 0000000..0abbf80
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/nestedFLWOGR2.sqlpp
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+select element (
+    select element k
+    from  if ((i > j))
+        then i
+        else j as k
+    where (k < 10)
+)
+from  [1,2,30,(
+        select element tmp
+        from  number as tmp
+    )] as i,
+      {{4,5,6}} as j
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/nestedFLWOGR3.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/nestedFLWOGR3.sqlpp
new file mode 100644
index 0000000..f82a3b6
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/nestedFLWOGR3.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+select element {'sig_name':sig_name,'total_count':sig_sponsorship_count,'chapter_breakdown':by_chapter}
+from  Event as event,
+      event.sponsoring_sigs as sponsor
+with  es as {'event':event,'sponsor':sponsor}
+group by sponsor.sig_name as sig_name
+with  sig_sponsorship_count as count(es),
+      by_chapter as (
+      select element {'chapter_name':chapter_name,'escount':count(es)}
+      from  es as e
+      group by e.sponsor.chapter_name as chapter_name
+  )
+order by sig_sponsorship_count desc
+limit 5 offset 2
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/nestedFor.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/nestedFor.sqlpp
new file mode 100644
index 0000000..bee2f90
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/nestedFor.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.
+ */
+
+select element {'name':user.name,'movie':mv.movie}
+from  User as user,
+      Movie as mv
+where some i in user.interests satisfies (i.movie = mv.movie)
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/numberInFieldAccessor.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/numberInFieldAccessor.sqlpp
new file mode 100644
index 0000000..d65197a
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/numberInFieldAccessor.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.
+ */
+
+select element {'name':user.name,'movie':mv.movie}
+from  User as user,
+      Movie as mv
+where some i in user.interests satisfies (i.movie = mv.movie[2])
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/select_clause_sugar.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/select_clause_sugar.sqlpp
new file mode 100644
index 0000000..bddd911
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/select_clause_sugar.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.
+ */
+
+select x as "value"
+from [ 10, 20, 30, 10, 10 ] as x
+where x = 10;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/select_from_where_sugar.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/select_from_where_sugar.sqlpp
new file mode 100644
index 0000000..e64afd2
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/select_from_where_sugar.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.
+ */
+
+select element x
+from [ 10, 20, 30, 10, 10 ] as x
+where x = 10;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/tuple_nav.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/tuple_nav.sqlpp
new file mode 100644
index 0000000..6ebd598
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/tuple_nav.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.
+ */
+
+{ 'id' : 1 }.name;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/tuple_nav_delimited_identifier.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/tuple_nav_delimited_identifier.sqlpp
new file mode 100644
index 0000000..df06b40
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/tuple_nav_delimited_identifier.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.
+ */
+
+{'e' : 1 }."e";
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/tuple_nav_mutiple_steps.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/tuple_nav_mutiple_steps.sqlpp
new file mode 100644
index 0000000..486a976
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/tuple_nav_mutiple_steps.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.
+ */
+
+{'n' : 1, 'a1 a2' : { 'n' : 2, 'b1 b2' : {'n' : 3}}}."a1 a2"."b1 b2".n;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/tuple_nav_quotes.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/tuple_nav_quotes.sqlpp
new file mode 100644
index 0000000..10f97ab
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/tuple_nav_quotes.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.
+ */
+
+{ 'author-id' : 2 }."author-id";
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/union.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/union.sqlpp
new file mode 100644
index 0000000..56464ba
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/union.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.
+ */
+
+
+select element l
+from  foo1() as l
+union
+select element l
+from  foo2() as l
+union
+select element l
+from  foo3() as l;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/utf-8.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/utf-8.sqlpp
new file mode 100644
index 0000000..ca2640f
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/utf-8.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.
+ */
+
+string_to_codepoint('äöß');
+string_to_codepoint('迎');
+/* currently fails (issue 277) string-to-codepoint("欢")  */
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/variables.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/variables.sqlpp
new file mode 100644
index 0000000..7611e3e
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/variables.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.
+ */
+
+with  a as 1,
+      b as 1
+select element (b - a)
+;
diff --git a/asterix-app/src/test/resources/parserts/queries_sqlpp/where_clause.sqlpp b/asterix-app/src/test/resources/parserts/queries_sqlpp/where_clause.sqlpp
new file mode 100644
index 0000000..6a5e766
--- /dev/null
+++ b/asterix-app/src/test/resources/parserts/queries_sqlpp/where_clause.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 sensors AS r
+where r.reading = 0.2
+select element r.reading;
\ No newline at end of file